UMKPointAnnotation* pointAnnotation = [[UMKPointAnnotation alloc]init];
coor1.latitude = baiduModel.latitude;
coor1.longitude = baiduModel.longitude;
pointAnnotation.voucherType = UMKVoucherCoupon ;
pointAnnotation.coordinate = coor1;
pointAnnotation.couponID = baiduModel.couponID;
pointAnnotation.title = baiduModel.businessName;
[arr addObject:pointAnnotation];
[_mapView addAnnotations:arr] ;
- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation
{
NSString *identifier = @"baidu";
BMKPinAnnotationView *annotationView = nil;
if (!annotationView) {
annotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(0, 0,annotationView.image.size.width, annotationView.image.size.height);
[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
annotationView.enabled = YES;
annotationView.userInteractionEnabled = YES;
//如果想传值,我们可以这样
UMKPointAnnotation *ffff = annotation;
btn.tag = ffff.couponID;
[annotationView addSubview:btn];
},
return annotationView;
}
-(void)btnAction:(UIButton *)sender
{
//这样就可以输出你想要传的ID值了
}