How to tell a rightCalloutAccessoryView has been touched for MapKit

二次信任 提交于 2019-12-10 18:35:07

问题


I have a MKAnnotationView being allocated with a DetailDisclosure button being displayed on the right side of the annotation. How would I go about knowing when a user clicked on the annotation button? This is what my code looks like right now -

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = rightButton;
pinView.animatesDrop = YES;

Is there a built in method to detect when a accessory view has been touched? I'm guessing it would be like the UITableView methods, but I can't find anything. Thanks for any help.


回答1:


You need some object to be set as your map view's delegate, and implement the MKMapViewDelegate protocol method -mapView:annotationView:calloutAccessoryControlTapped:.




回答2:


Implement mapView:annotationView:calloutAccessoryControlTapped: method in your MKMapViewDelegate.



来源:https://stackoverflow.com/questions/2607431/how-to-tell-a-rightcalloutaccessoryview-has-been-touched-for-mapkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!