0
我想链接两个视图控制器内我的应用程序,但我不知道如何将它们连接它们没有附加到我的tableview单元格。我希望它只是一个带有标识符的简单segue,所以我可以用标识符调用perfrom segue。但是,我只能通过将它从我的单元格拖到下一个视图控制器来创建一个segue。Swift之间的VC之间没有什么可链接
下面是我试图链接的两个VC的图像,显示了被选中的单元格。
http://imgur.com/gallery/PWJol
我无法弄清楚如何做到这一点。
这是我使用的代码,这似乎是正确的。我希望它在选中一行时传递并传递所选行的标签名称。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.NameToPass = DietSelectionTableViewCell.TypesOfDiets[indexPath.row]
self.performSegue(withIdentifier: "DietInformation", sender: self)
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "DietInformation" {
if let destinationVC = segue.destination as? DietInformationViewController {
destinationVC.DietTypeLabelText = self.NameToPass
}
}
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
在您从segueing现场,按住Ctrl键单击顶部的橙色圆圈(代表视图控制器本身)和阻力到您继续使用的视图控制器。 – pbasdf