首页 文章

将数据传递给注释中的segue?

提问于
浏览
1

我有一个带有注释的mapView,这些注释是使用CloudKit中的数据创建的 . 我使用注释中的信息按钮在点击按钮时调用segue .

我知道我可以像这样轻松传递 Headers 和副 Headers ..

func mapView(mapView: MKMapView, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {

    let detailTitle = annotationView.annotation.title

    performSegueWithIdentifier("fromMap", sender: self)

}

我的问题是我需要发送的不仅仅是MKAnnotation视图中的数据 . 我还有一些来自CloudKit记录的其他字段,我需要通过segue传递给细节控制器,但我不能为我的生活找出如何做到这一点 .

使用tableView很容易,因为你有indexPath信息,但据我所知,你没有注释 .

我查看了我可以在网上找到的所有帖子和信息,但我仍然卡住了 .

任何帮助,将不胜感激 .

1 回答

  • 3

    您可以使用 tuple 只发送多个对象并从目标视图控制器捕获它们

    func mapView(mapView: MKMapView, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
      let detailTitle = annotationView.annotation.title
      performSegueWithIdentifier("fromMap", sender: (annotation.title, annotation.subtitle, annotation.address))
    }
    

相关问题