MKAnnotation с пользовательским bubleview в кнопке поставить для IOS?
Я создал BubbleView
в просмотре карты. В пузыре я положил кнопку, но я не нажимаю на кнопку.
Как я могу реализовать, пожалуйста, помогите мне.
Я пытался.......
customCalloutView.h
#import <UIKit/UIKit.h>
@interface customCalloutView : UIView
@property (nonatomic, retain) IBOutlet UIButton *BubbleBtn;
customCalloutView.m
#import "customCalloutView.h"
@implementation customCalloutView
{
}
@end
Метод делегирования mapview в другом классе
- (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");
}