我想知道是否有办法添加UITextField
&在UIButton
标注气泡中MKPinAnnotationView
,如果用户点击了按钮,它会调用某种方法吗?
答案 0 :(得分:0)
您可以使用以下代码添加自定义视图而不是MKAnnotationView
..
您可以使用addSubview
属性添加任何控件...
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *customPinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( customPinView == nil )
customPinView = [[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID];
customPinView.canShowCallout = YES;
//customPinView.animatesDrop = YES;
customPinView.image = [UIImage imageNamed:@"yourImageName"];//write your imagename
// and add UIButton with bellow code
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(ShowStoreDetail:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;here
}
else {
[mapView.userLocation setTitle:@"I am here"];
}
return pinView;
}
我希望它对你有用......
:)