我有两个 View Controller 。其中之一是搜索 View Controller ,它使用 Mapkit 来允许用户搜索位置。
我希望能够单击特定的单元格,然后将该单元格的副标题分配给另一个 View Controller 中的文本字段。有谁知道如何做到这一点?
最佳答案
您可以实现以下UITableViewDelegate
方法。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
let cell = tableView.cellForRow(at: indexPath) as! MyCell
let vc = MyViewController()
vc.subtitle = cell.subTitle.text
present(vc, animated: true, completion: nil)
}
关于ios - 在两个 View Controller 之间传递mapkit数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44754858/