实际上,我正在我的应用程序中开发一些东西,在我的应用程序中显示注释MKMapView
,这些注释应该是可点击的,并将参数传递给方法。
现在的问题是如何在点击公开按钮时将参数传递给下一个函数。
对于注释的格式,我使用- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation
显示披露按钮的方法。但问题是,如何从Annotation
当前显示的对象中获取值?
我的代码Annotation
(仅相关部分):
@synthesize coordinate, id, title, subtitle;
+ (id)annotationWithCoordinate:(CLLocationCoordinate2D)coordinate {
return [[[[self class] alloc] initWithCoordinate:coordinate] autorelease];
}
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate {
self = [super init];
if(nil != self) {
self.coordinate = coordinate;
}
return self;
}
并且当触摸公开按钮时,应该调用该方法并作为参数- (void)displayInfo:(NSNumber *) anId;
移交。Annotation.id
anId
使用该代码生成披露按钮:
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
dropPin.rightCalloutAccessoryView = disclosureButton;
dropPin.animatesDrop = YES;
dropPin.canShowCallout = YES;
所以-问题:
如何将该参数传递给函数或读取id
单击的Annotation
?
我想我可以使用 UIButton 的选择器(但是 - 如何传递 id?)或使用- (void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
(再次 - 如何传递 id?)来处理公开按钮上的点击。
我希望你知道我的意思,非常感谢你的回答!:)