作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目前我正在从 API 中提取 JSON 并将其发布到 MapKit map 。它从 API 中提取并将其解析为类市场数组,每个邮政编码的大小都不同。目前,我正在尝试获取我单击的特定注释标注的信息,并在单击信息按钮时将其发送到新的 View Controller 。
这是我准备 segue 的代码,当按下信息按钮时:
//This method gets ran when the information button is pressed on the Annotation's Callout
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl) {
let market = view.annotation as! Market
performSegue(withIdentifier: "callout", sender: market)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destination = segue.destination as! CalloutViewController
destination.market = //Yes this line isn't completed, Not sure how to get the current class from the annotation's callout when it is pressed!
let backItem = UIBarButtonItem()
backItem.title = "Back"
navigationItem.backBarButtonItem = backItem
}
这是 Callout View Controller(我正在尝试获取信息以继续使用的那个。):
class CalloutViewController: UIViewController {
let market: Market! = nil
@IBOutlet weak var testView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.navigationController?.navigationBar.tintColor = UIColor.white
}
最佳答案
应该是:
destination.market = sender as? Market
还是我遗漏了什么?
关于ios - 如何将来自 MapKit 注释的信息发送到新的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48360416/
我是一名优秀的程序员,十分优秀!