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