Guest User

Untitled

a guest
May 23rd, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
  2.  
  3.  
  4. static NSString *mapIdentifier=@"mapIdentifier";
  5.  
  6. MKAnnotationView *myAnnotation=[mapView dequeueReusableAnnotationViewWithIdentifier:mapIdentifier];
  7.  
  8.  
  9. if (!myAnnotation) {
  10.  
  11. myAnnotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:mapIdentifier];
  12.  
  13.  
  14. if ((annotation.coordinate.latitude == [_tripInfoDetails[@"park_lat"] doubleValue])
  15. && (annotation.coordinate.longitude == [_tripInfoDetails[@"park_long"] doubleValue]))
  16. {
  17. myAnnotation.tag=7;
  18. myAnnotation.image=[UIImage imageNamed:@"pin7@2x.png"];
  19.  
  20. }
  21.  
  22. else if ((annotation.coordinate.latitude == [_tripInfoDetails[@"origin_lat"] doubleValue])
  23. && (annotation.coordinate.longitude == [_tripInfoDetails[@"origin_long"] doubleValue]))
  24.  
  25.  
  26. {
  27. myAnnotation.tag=1;
  28. myAnnotation.image=[UIImage imageNamed:@"pin1@2x.png"];
  29.  
  30. }
  31. else{
  32. myAnnotation.tag=1;
  33. myAnnotation.image=[UIImage imageNamed:@"pin6@2x.png"];
  34. }
  35.  
  36.  
  37. }
  38.  
  39. return myAnnotation;
  40.  
  41. }
  42. - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
  43.  
  44. NSLog(@" pin selected ");
  45. [self openInMap:invitationArray];
  46.  
  47. calloutView.tag=1;
  48. calloutView = [[MAKRCalloutView alloc] initWithFrame:CGRectMake(0.0, 0.0, 292.0, 90.0)];
  49. calloutView.titleLabel.text = view.annotation.title;
  50. calloutView.informationLabel.text =seats;
  51. calloutView.distanceLabel.text=confirmStatusStr;
  52. calloutView.distanceLabel.textColor=[UIColor redColor];
  53.  
  54. calloutView.distanceLabel.userInteractionEnabled = YES;
  55.  
  56. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(navigateToTrip)];
  57. tapGesture.delegate = self;
  58. tapGesture.numberOfTapsRequired = 1;
  59. [calloutView addGestureRecognizer:tapGesture];
  60.  
  61. [calloutView.imageView setImageWithURL :[NSURL URLWithString:imageStr]];
  62.  
  63. calloutView.ratingView.value=ratingStr;
  64. calloutView.offerLabel.text=offerStr;
  65.  
  66. calloutView.reviewLabel.text=@"0 Reviews";
  67. calloutView.subtitleLabel.text = view.annotation.subtitle;
  68.  
  69.  
  70. calloutView.center = CGPointMake(CGRectGetWidth(view.bounds) / 2.0, 0.0);
  71. view.layer.zPosition = 0;
  72.  
  73. [view addSubview:calloutView];
  74.  
  75. }
  76.  
  77.  
  78.  
  79. -(void)navigateToTrip
  80. {
  81. TravellerProfileVC *travellerProfileVC=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"travellerProfileTVC"];
  82.  
  83. travellerProfileVC.userDetails=dict;
  84.  
  85. travellerProfileVC.tripInfoDetails=_tripInfoDetails;
  86.  
  87. travellerProfileVC.toFavouritePage=_toFavouritePage;
  88.  
  89. [self.navigationController pushViewController:travellerProfileVC animated:YES];
  90.  
  91. }
  92.  
  93.  
  94. - (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view {
  95. for (UIView *subview in view.subviews) {
  96. if (![subview isKindOfClass:[MAKRCalloutView class]]) {
  97.  
  98.  
  99. NSLog(@" inside if");
  100. calloutView.hidden=YES;
  101. }
  102.  
  103. else if ([subview isKindOfClass:[MAKRCalloutView class]]) {
  104.  
  105. NSLog(@" inside else if condition");
  106. [self navigateToTrip];
  107.  
  108. }
  109.  
  110. }
  111. }
  112.  
  113.  
  114.  
  115. i want if the call out view is tapped then it shud navigate to [navigateToTrip method] and if tapped somewhere outside the callout view then it shud disappear
Add Comment
Please, Sign In to add comment