Iphone 如何在MKPinAnnotationView详图索引中添加UIExtField和uibutton?
我想知道是否有办法在MKPinAnnotationView标注气泡中添加UIExtField和UIButton,反过来,如果用户单击按钮,它将调用一些方法?您可以添加自定义视图,而不是使用下面的代码添加MKAnnotationView 您可以使用addSubview属性简单地添加任何控件Iphone 如何在MKPinAnnotationView详图索引中添加UIExtField和uibutton?,iphone,mkmapview,mkannotation,callouts,Iphone,Mkmapview,Mkannotation,Callouts,我想知道是否有办法在MKPinAnnotationView标注气泡中添加UIExtField和UIButton,反过来,如果用户单击按钮,它将调用一些方法?您可以添加自定义视图,而不是使用下面的代码添加MKAnnotationView 您可以使用addSubview属性简单地添加任何控件 -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {
-(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;
}
我希望它对你有用
: