Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. - (IBAction)playBtn:(id)sender {
  2.  
  3. timer = [NSTimer scheduledTimerWithTimeInterval:(4.0) target:self selector:@selector(control) userInfo:nil repeats:YES];
  4.  
  5. }
  6.  
  7. -(void)control{
  8. NSMutableArray *annotationArray = [[[NSMutableArray alloc] init] autorelease];
  9.  
  10. switch (value%2) {
  11. case 0:
  12. {
  13.  
  14. // Create some annotations
  15. Annotation *annotation = nil;
  16.  
  17. annotation = [[Annotation alloc] init];
  18. annotation.coordinate = CLLocationCoordinate2DMake(29.7161,-95.3906);
  19. annotation.color = RGB(13, 0, 182);
  20. annotation.title = @"17";
  21. [annotationArray addObject:annotation];
  22. [annotation release];
  23.  
  24. annotation = [[Annotation alloc] init];
  25. annotation.coordinate = CLLocationCoordinate2DMake(30.168456,-95.504480);
  26. annotation.color = RGB(0, 182, 146);
  27. annotation.title = @"16";
  28. [annotationArray addObject:annotation];
  29. [annotation release];
  30.  
  31.  
  32. // Center map
  33. //self.mapView.visibleMapRect = [self makeMapRectWithAnnotations:annotationArray];
  34.  
  35. // Add to map
  36. //[self.mapView addAnnotations:annotationArray];
  37. }
  38. break;
  39. case 1:
  40. {
  41. // Create some annotations
  42. Annotation *annotation = nil;
  43.  
  44. annotation = [[Annotation alloc] init];
  45. annotation.coordinate = CLLocationCoordinate2DMake(29.7161,-95.3906);
  46. annotation.color = RGB(13, 0, 182);
  47. annotation.title = @"27";
  48. [annotationArray addObject:annotation];
  49. [annotation release];
  50.  
  51. annotation = [[Annotation alloc] init];
  52. annotation.coordinate = CLLocationCoordinate2DMake(30.168456,-95.504480);
  53. annotation.color = RGB(0, 182, 146);
  54. annotation.title = @"25";
  55. [annotationArray addObject:annotation];
  56. [annotation release];
  57.  
  58. }
  59. break;
  60. }
  61. [self.mapView addAnnotations:annotationArray];
  62. [mapView setNeedsDisplay];
  63. value++;
  64.  
  65. BOOL annFound = NO;
  66.  
  67. //loop through the map view's annotations array to find annotation id# 42...
  68. for (id<MKAnnotation> ann in mapView.annotations)
  69. {
  70. if ([ann isKindOfClass:[MyAnnotationClass class]])
  71. {
  72. MyAnnotationClass *myAnn = (MyAnnotationClass *)ann;
  73. if (myAnn.annotationId == 42)
  74. {
  75. annFound = YES;
  76. myAnn.title = @"some new title";
  77. break;
  78. }
  79. }
  80. }
  81.  
  82. if (!annFound)
  83. {
  84. //annotation id# 42 is not yet on the map.
  85. //create it and add to map...
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement