通过单击表视图中的单元格 – Swift iOS打开新的视图控制器
发布时间:2020-12-14 05:55:57 所属栏目:百科 来源:网络整理
导读:我有以下onClick函数 func tableView(tableView: UITableView,didSelectRowAtIndexPath indexPath: NSIndexPath) { tableView.deselectRowAtIndexPath(indexPath,animated: true) let row = indexPath.row println("Row: (row)") println(meetingArray[row]
我有以下onClick函数
func tableView(tableView: UITableView,didSelectRowAtIndexPath indexPath: NSIndexPath) { tableView.deselectRowAtIndexPath(indexPath,animated: true) let row = indexPath.row println("Row: (row)") println(meetingArray[row] as! String) } 它打印出单击的单元格上的文本。工作正常 我只是想知道如何设置一个功能,这将引导您到新的视图控制器
编程方式:
let destination = UIViewController() // Your destination navigationController?.pushViewController(destination,animated: true) 故事板: 之后,您可以使用以下代码创建“目的地”并将其推送到导航控制器: let storyboard = UIStoryboard(name: "Main",bundle: Bundle.main) let destination = storyboard.instantiateViewController(withIdentifier: "YourViewController") as! YourViewController navigationController?.pushViewController(destination,animated: true) Segue公司: performSegue(withIdentifier: "segue",sender: self) override func prepare(for segue: UIStoryboardSegue,sender: Any?) { if segue.identifier == "segue" { // Setup new view controller } } 编辑:为Swift 3.x更新 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |