Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
- static NSString *mapIdentifier=@"mapIdentifier";
- MKAnnotationView *myAnnotation=[mapView dequeueReusableAnnotationViewWithIdentifier:mapIdentifier];
- if (!myAnnotation) {
- myAnnotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:mapIdentifier];
- if ((annotation.coordinate.latitude == [_tripInfoDetails[@"park_lat"] doubleValue])
- && (annotation.coordinate.longitude == [_tripInfoDetails[@"park_long"] doubleValue]))
- {
- myAnnotation.tag=7;
- myAnnotation.image=[UIImage imageNamed:@"pin7@2x.png"];
- }
- else if ((annotation.coordinate.latitude == [_tripInfoDetails[@"origin_lat"] doubleValue])
- && (annotation.coordinate.longitude == [_tripInfoDetails[@"origin_long"] doubleValue]))
- {
- myAnnotation.tag=1;
- myAnnotation.image=[UIImage imageNamed:@"pin1@2x.png"];
- }
- else{
- myAnnotation.tag=1;
- myAnnotation.image=[UIImage imageNamed:@"pin6@2x.png"];
- }
- }
- return myAnnotation;
- }
- - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
- NSLog(@" pin selected ");
- [self openInMap:invitationArray];
- calloutView.tag=1;
- calloutView = [[MAKRCalloutView alloc] initWithFrame:CGRectMake(0.0, 0.0, 292.0, 90.0)];
- calloutView.titleLabel.text = view.annotation.title;
- calloutView.informationLabel.text =seats;
- calloutView.distanceLabel.text=confirmStatusStr;
- calloutView.distanceLabel.textColor=[UIColor redColor];
- calloutView.distanceLabel.userInteractionEnabled = YES;
- UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(navigateToTrip)];
- tapGesture.delegate = self;
- tapGesture.numberOfTapsRequired = 1;
- [calloutView addGestureRecognizer:tapGesture];
- [calloutView.imageView setImageWithURL :[NSURL URLWithString:imageStr]];
- calloutView.ratingView.value=ratingStr;
- calloutView.offerLabel.text=offerStr;
- calloutView.reviewLabel.text=@"0 Reviews";
- calloutView.subtitleLabel.text = view.annotation.subtitle;
- calloutView.center = CGPointMake(CGRectGetWidth(view.bounds) / 2.0, 0.0);
- view.layer.zPosition = 0;
- [view addSubview:calloutView];
- }
- -(void)navigateToTrip
- {
- TravellerProfileVC *travellerProfileVC=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"travellerProfileTVC"];
- travellerProfileVC.userDetails=dict;
- travellerProfileVC.tripInfoDetails=_tripInfoDetails;
- travellerProfileVC.toFavouritePage=_toFavouritePage;
- [self.navigationController pushViewController:travellerProfileVC animated:YES];
- }
- - (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view {
- for (UIView *subview in view.subviews) {
- if (![subview isKindOfClass:[MAKRCalloutView class]]) {
- NSLog(@" inside if");
- calloutView.hidden=YES;
- }
- else if ([subview isKindOfClass:[MAKRCalloutView class]]) {
- NSLog(@" inside else if condition");
- [self navigateToTrip];
- }
- }
- }
- 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