Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
- {
- // If it's the user location, just return nil
- if ([annotation isKindOfClass:[MKUserLocation class]])
- return nil;
- // Handle custom annotations
- if ([annotation isKindOfClass:[NAME_OF_CLASS_IMPLEMENTING_MKANNOTATION_PROTOCOL class]])
- {
- // Try to dequeue an existing annotation view first
- MKAnnotationView *annotationView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"AnnotationViewIdentifier"];
- if (!annotationView)
- {
- // If an existing pin view was not available, create one
- annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"AnnotationViewIdentifier"];
- annotationView.canShowCallout = YES;
- // set callout
- UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
- annotationView.rightCalloutAccessoryView = rightButton;
- }
- else
- {
- annotationView.annotation = annotation;
- }
- return annotationView;
- }
- return nil;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement