简体   繁体   English

单击注释后,如何将数据传递到其视图控制器?

[英]When a annotation is clicked how can I pass data to its view controller?

When an MKAnnotation is clicked I need to call a function in its view controller, and pass it two NSStrings contained in the annotation. 单击MKAnnotation时,我需要在其视图控制器中调用一个函数,并将其包含在注释中的两个NSString传递给它。 How can I achieve this? 我该如何实现?

Just assign your view controller as the map view's delegate and implement 只需将您的视图控制器分配为地图视图的delegate并实现

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

MKAnnotationView has an annotation property that you can use to get your strings. MKAnnotationView具有一个annotation属性,可用于获取字符串。

Probably the annotations are some kind of buttons? 注释可能是某种按钮吗? In this case, they are the sender of the action -> A reference to the clicked annotation is passed as argument to the called function! 在这种情况下,它们是动作的发送者->对单击的批注的引用将作为参数传递给被调用的函数!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将注释标题传递给另一个视图控制器 - How to pass annotation title to another view controller 当我启动应用程序时,如何将xcode中的视图控制器重置为其状态 - how can i reset a view controller in xcode to its state when i started the app 单击大头针注释时如何显示另一个视图 - how to show another view when clicked on pin annotation 我如何将数据传递回父视图控制器。 正在使用addSubView方法显示子视图 - How can i pass data back to parent view controller. am using addSubView method to show child view 无法通过数据 object 在视图 controller 中查看 controller - Can't pass a data object to view controller inside a view controller 点击注释时将数据传递给另一个视图控制器 - passing data to another view controller when tapping on annotation 变暗 Map 单击/查看注释时查看 - Darken Map View when Annotation Clicked/Viewed 单击地图注释时显示另一个视图 - show another view when map annotation are clicked 在iphone中单击按钮时如何查看tableview控制器 - how to view a tableview controller when a button is clicked in iphone 如何将标签栏控制器中的数据传递到其中一个选项卡? - How do I pass data from a tab bar controller to one of its tabs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM