내 응용 프로그램 내에서 두 개의 View Controller를 연결하려고하지만 내 tableview 셀에 연결하지 않고 연결하는 방법을 알아낼 수 없습니다. 식별자가있는 간단한 segue가되기를 바라고 식별자로 perfrom segue를 호출 할 수 있습니다. 그러나, 나는 그 셀을 다음보기 컨트롤러로 드래그하여 단절을 만들 수 있습니다.링크가없는 VC 사이의 Swift Segue
다음은 링크하려는 두 VC의 이미지로 셀이 선택되었음을 보여줍니다.
http://imgur.com/gallery/PWJol
나는이 작업을 수행하는 방법을 알아낼 수 없습니다.
이것은 올바른 것으로 보이는 segue에 사용하는 코드입니다. 행이 선택되면 선택하고 선택한 행의 레이블 이름을 전달해야합니다. 뷰 컨트롤러 자체에서
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.
}
을 드래그 (뷰 컨트롤러 자체를 나타냄) 상단에 주황색 원을 Ctrl 키 보기 컨트롤러에 segueing하고 있습니다. – pbasdf