Guest User

Untitled

a guest
Jul 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. [self.mapView selectAnnotation:annotation animated:YES];
  2.  
  3. @interface MyAnnotation : NSObject <MKAnnotation> {
  4. NSString *title;
  5. NSString *subtitle;
  6. }
  7.  
  8. @property (nonatomic, copy) NSString *title;
  9. @property (nonatomic, copy) NSString *subtitle;
  10.  
  11. @end
  12.  
  13. #import "MyAnnotation.h"
  14.  
  15. @implementation MyAnnotation
  16.  
  17. @synthesize title, subtitle;
  18.  
  19. @end
  20.  
  21. MyAnnotation *foo = [[MyAnnotation alloc] init];
  22. foo.title = @"I am Foo";
  23. foo.subtitle = "I am jus' a subtitle";
  24.  
  25. -(MKAnnotationView *)mapView:(MKMapView *)_mapView viewForAnnotation:(id<MKAnnotation>)annotation
  26. {
  27. static NSString *AnnotationViewIdentifier = @"AnnotationViewIdentifier";
  28.  
  29. MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewIdentifier];
  30. if (annotationView == nil)
  31. {
  32. annotationView = [[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:AnnotationViewIdentifier]autorelease];
  33. }
  34.  
  35. annotationView.canShowCallout = YES;
  36.  
  37. return annotationView;
  38. }
Add Comment
Please, Sign In to add comment