ios - Map View - Disclosure Button to a View -
i started programming recently, , have question! have created mapview annotation , disclosure button.
how can create multiple annotations disclosure button that, after tap, go different descriptions based on annotation choice?
this code:
@synthesize mapview; -(void)viewdidload { [super viewdidload]; [mapview setmaptype:mkmaptypehybrid]; [mapview setzoomenabled:yes]; [mapview setscrollenabled:yes]; [mapview setdelegate:self]; mkcoordinateregion bigben = { {0.0, 0.0} , {0.0, 0.0} }; bigben.center.latitude = 51.50063; bigben.center.longitude = -0.124629; bigben.span.longitudedelta = 0.02f; bigben.span.latitudedelta = 0.02f; [mapview setregion:bigben animated:yes]; annotation *ann1 = [[annotation alloc] init]; ann1.title = @"big ben"; ann1.subtitle = @"your subtitle"; ann1.coordinate = bigben.center; [mapview addannotation: ann1]; mkcoordinateregion bridge = { {0.0, 0.0} , {0.0, 0.0} }; bridge.center.latitude = 51.500809; bridge.center.longitude = -0.120914; bridge.span.longitudedelta = 0.02f; bridge.span.latitudedelta = 0.02f; [mapview setregion:bridge animated:yes]; annotation *ann2 = [[annotation alloc] init]; ann2.title = @"westminster bridge"; ann2.subtitle = @"your subtitle"; ann2.coordinate = bridge.center; [mapview addannotation:ann2]; } -(mkannotationview *) mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation { mkpinannotationview *mypin=[[mkpinannotationview alloc] initwithannotation:annotation reuseidentifier:@"current"]; mypin.pincolor = mkpinannotationcolorpurple; uibutton *advertbutton = [uibutton buttonwithtype:uibuttontypedetaildisclosure]; [advertbutton addtarget:self action:@selector(button:) forcontrolevents:uicontroleventtouchupinside]; mypin.rightcalloutaccessoryview = advertbutton; mypin.draggable = no; mypin.highlighted = yes; mypin.animatesdrop=true; mypin.canshowcallout = yes; return mypin; }
the usual way implement -mapview:annotationview:calloutaccessorycontroltapped:
in map view delegate. can use annotaionview parameter decide annotaion tapped , information want display.
Comments
Post a Comment