ios - Add thumbnail to an MKPinAnnotation -
i have custom mkpinannotation wich need add image(like thumbnail). should able open image fullscreen tapping it. best way go around doing this?
a couple of thoughts.
if don't want pin on map, rather custom image, can set map's delegate , write
viewforannotation
like:- (mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id <mkannotation>)annotation { if ([annotation iskindofclass:[customannotation class]]) { static nsstring * const identifier = @"mycustomannotation"; // if need access custom properties custom annotation, create reference of appropriate type: customannotation *customannotation = annotation; // try dequeue annotationview mkannotationview* annotationview = [mapview dequeuereusableannotationviewwithidentifier:identifier]; if (annotationview) { // if found one, update annotation appropriately annotationview.annotation = annotation; } else { // otherwise, let's create 1 annotationview = [[mkannotationview alloc] initwithannotation:annotation reuseidentifier:identifier]; annotationview.image = [uiimage imagenamed:@"myimage"]; // if want callout "disclosure" button on annotationview.canshowcallout = yes; annotationview.rightcalloutaccessoryview = [uibutton buttonwithtype:uibuttontypedetaildisclosure]; // if want, if you're using quartzcore.framework, can add // visual flourishes annotation view: // // [annotationview.layer setshadowcolor:[uicolor blackcolor].cgcolor]; // [annotationview.layer setshadowopacity:1.0f]; // [annotationview.layer setshadowradius:5.0f]; // [annotationview.layer setshadowoffset:cgsizemake(0, 0)]; // [annotationview setbackgroundcolor:[uicolor whitecolor]]; } return annotationview; } return nil; }
if standard callout (as shown above), can tell map want when user taps on callout's disclosure button:
- (void)mapview:(mkmapview *)mapview annotationview:(mkannotationview *)view calloutaccessorycontroltapped:(uicontrol *)control { if (![view.annotation iskindofclass:[customannotation class]]) return; // whatever want go next view }
if want bypass callout disclosure button, rather go directly view controller when tap on annotation view, would:
set
canshowcallout
no
inviewforannotation
; andwrite own
didselectannotationview
for more information, see annotating maps in location awareness programming guide.
Comments
Post a Comment