objective c - MKAnnotation looses title and subtitle when given a custom icon -
ok making ios application using mapkit framework. have got functionality working having trouble when changing icon of annotation. can change annotations icon when annotation looses it's title , subtitle values (nothing pops when tapped). think maybe issue due not giving annotation identifier when first made not sure...
if let me know whats going on appreciated!
the code add annotation is:
-(void)addannotationatlattitude:(double)lattitude withlongitude:(double)longitude withtitle:(nsstring *)title withsubtitle:(nsstring *)subtitle{ //handles adding off anotation cllocationcoordinate2d annotationcoord; annotationcoord.latitude = lattitude; annotationcoord.longitude = longitude; mkpointannotation *annotationpoint = [[mkpointannotation alloc] init]; annotationpoint.coordinate = annotationcoord; annotationpoint.title = title; annotationpoint.subtitle = subtitle; [self.messagemap addannotation:annotationpoint]; }
and code change icon (via delegate method ) is:
-(mkannotationview *)mapview:(mkmapview *)_mapview viewforannotation:(id <mkannotation>)annotation { static nsstring *annotationviewid = @"annotationviewid"; mkannotationview *annotationview = (mkannotationview *)[_mapview dequeuereusableannotationviewwithidentifier:annotationviewid]; if (annotationview == nil) { annotationview = [[mkannotationview alloc] initwithannotation:annotation reuseidentifier:annotationviewid]; } annotationview.image = [uiimage imagenamed:@"custommapannotationicon"];//mycustom image annotationview.annotation = annotation; return annotationview; }
are annotationview.enabled , annotationview.canshowcallout set yes?
Comments
Post a Comment