【发布时间】:2018-06-28 21:41:14
【问题描述】:
在我的 MapView 中,我有几个 MKAnnotation 引脚,每个引脚都配置了 viewFor 以显示右侧带有“I”按钮的小弹出窗口。
现在我正在尝试找到一种方法来通过点击弹出窗口中的披露“I”按钮来创建一个转场 - 我看到这可以通过
func mapView(... calloutAccessoryControlTapped control: UIControl)
但是,因为在storyboard中MKAnnotation pin当然不会出现,所以我不知道如何使用control-drag方法创建segue并获取相应的segue ID。
我的解决方法 - 我基本上实例化另一个我希望在按下“I”按钮时切换到新视图的视图控制器
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
let settingVC = self.storyboard?.instantiateViewController(withIdentifier: "SetNotifPageID") as! SetNotificationViewController
self.present(settingVC, animated: true, completion: nil)
}
但是有没有更好的方法来执行此操作,比如从情节提要中,或者使用更正确的方法?
【问题讨论】:
标签: ios swift mapkit segue xcode-storyboard