开发者

Retain pin coordinates in calloutAccessoryControlTapped action

开发者 https://www.devze.com 2023-04-02 07:11 出处:网络
Can I retain pin coordinates for an calloutA开发者_JAVA百科ccessoryControlTapped action? I want to retain those coordinates to the next view. When you tap a pin, and subsequently go to the next view,

Can I retain pin coordinates for an calloutA开发者_JAVA百科ccessoryControlTapped action? I want to retain those coordinates to the next view. When you tap a pin, and subsequently go to the next view, i want to use the pin coordinates again. How do I retain those coordinates from that pin?


In the calloutAccessoryControlTapped method, you can access the annotation tapped using view.annotation and the coordinates will be in view.annotation.coordinate.

You can add a property of type CLLocationCoordinate2D to the next view and set it equal to view.annotation.coordinate.


Ask the MKMapView for its selectedAnnotations. As there can only be one, and this will be the one showing a callout, you can take the coordinate in your mapView:annotationView:calloutAccessoryControlTapped: method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号