Pages

Sunday, April 25, 2010

Iphone: MapKit - Move to Next View on click of MKPinAnnotation Without using canShowCallout

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id ) annotation{
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"];
annView.animatesDrop =TRUE;
[annView setSelected:YES];
annView.pinColor = MKPinAnnotationColorRed;
[annView addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:nil];

return annView;
}


When we select the Annotation pin then it call following method

- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context{

// here we can put the code for moving next view

}

2 comments:

  1. I might be wrong, but shouldn't you autorelease annView ?
    MKPinAnnotationView *annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"] autorelease];

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete