Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
  2. {
  3. // If it's the user location, just return nil
  4. if ([annotation isKindOfClass:[MKUserLocation class]])
  5. return nil;
  6.  
  7. // Handle custom annotations
  8. if ([annotation isKindOfClass:[NAME_OF_CLASS_IMPLEMENTING_MKANNOTATION_PROTOCOL class]])
  9. {
  10. // Try to dequeue an existing annotation view first
  11. MKAnnotationView *annotationView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"AnnotationViewIdentifier"];
  12.  
  13. if (!annotationView)
  14. {
  15. // If an existing pin view was not available, create one
  16. annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"AnnotationViewIdentifier"];
  17. annotationView.canShowCallout = YES;
  18.  
  19. // set callout
  20. UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
  21. annotationView.rightCalloutAccessoryView = rightButton;
  22. }
  23. else
  24. {
  25. annotationView.annotation = annotation;
  26. }
  27.  
  28. return annotationView;
  29. }
  30.  
  31. return nil;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement