Hi all, in wich way could i call the function that open automatically my annotation (with title, subtitle, calloutaccessorybutton, etc), rather than to touch on the annotation on the mapview?
thanks in advance:)
Mat
Hi all, in wich way could i call the function that open automatically my annotation (with title, subtitle, calloutaccessorybutton, etc), rather than to touch on the annotation on the mapview?
thanks in advance:)
Mat
Implement MKMapViewDelegate
delegate;
Implement - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_;
; for example like this:
- (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_ {
MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"YourPinId"];
if (pin == nil) {
pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation_ reuseIdentifier: @"YourPinId"] autorelease];
}
else {
pin.annotation = annotation_;
}
pin.pinColor = MKPinAnnotationColorRed;
[pin setCanShowCallout:YES];
pin.animatesDrop = YES;
return pin;
}
Show the pin after the map has finished loading:
- (void) dropPin {
[mapView addAnnotation:self.annotation];
[mapView selectAnnotation:self.annotation animated:YES];
}
- (void) mapViewDidFinishLoadingMap: (MKMapView *) mapView_ {
// if done loading, show the call out
[self performSelector:@selector(dropPin) withObject:nil afterDelay:0.3];
}
This code has a property called annotation which implements MKAnnotation
. Also, it animates the pin drop too, but it should be fairly self-explaining.
HTH.