I created a BubbleView in mapview. In the bubble, I put the button, but I do not press the button.
How can I implement help me.
I tried.......
customCalloutView.h
customCalloutView.m
#import "customCalloutView.h" @implementation customCalloutView { } @end
Delegate mapview method in another class
- (MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { static NSString * identifier=@ "MyAnnotation"; NSLog(@"anotioni s:%@",annotation); //CLLocationCoordinate2D pinCoordinate = [self.pickupLocationView convertPoint:CGPointMake(self.pickupLocationView.frame.size.width / 2, self.pickupLocationView.frame.size.height) toCoordinateFromView:self.view]; MKAnnotationView *annotationView=(MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if (!annotationView) { annotationView=[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:identifier]; annotationView.image=[UIImage imageNamed:@"mapPin"]; } else { annotationView.annotation=annotation; } return annotationView; } - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view { customCalloutView *callOutView=nil; callOutView.userInteractionEnabled=YES; if (callOutView == nil) { NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"customCalloutView" owner:self options:nil]; callOutView=[nib objectAtIndex:0]; } [callOutView.BubbleBtn addTarget:self action:@selector(BtnDetailclick:) forControlEvents:UIControlEventTouchUpInside]; CGRect callOutViewFrame=callOutView.frame; callOutViewFrame.origin=CGPointMake(-callOutViewFrame.size.width/2+14 , -callOutViewFrame.size.height); callOutView.frame=callOutViewFrame; // [callOutView.BtnDetail setTitle:@"Change" forState:UIControlStateNormal]; [view addSubview:callOutView]; } -(IBAction)BtnDetailclick:(UIButton *)sender { NSLog(@"Hello"); }
source share