我整天都在努力解决“没有标识符的问题”错误并陷入困境。
错误消息:
SegueTest[41862:1585831] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Receiver (<SegueTest.TableViewController: 0x7feed6510260>) has no segue with identifier 'tableToCollectionSegue''
*** First throw call stack:
相关文件出错:
请在GitHub上检查我的Main.storyboard
。
Capture of segue configuration for ViewController ( Working)
Capture of segue configuration for TableViewController (❌ Getting error)
环境:
我在Main.storyboard中所做的事情:
创建了UINavigationController
作为初始视图控制器,并连接到RootViewController
作为根视图控制器
创建从UINavigationController
打开的RootViewController
作为模态视图
将Open Modal
按钮与模式UINavigationController
连接起来并命名为navigationSegue
创建ViewController
,TableViewController
和CollectionViewController
将模式UINavigationController
与ViewController
作为根视图控制器进行连接
将ViewController
与TableViewController
连接起来,作为名为viewToTableSegue
的触发segue(手动)
将TableViewController
与CollectionViewController
连接起来,作为名为tableToCollectionSegue
的触发segue(手动)
将Next
上的ViewController
按钮与@IBAction func didTapNext(_ sender: Any)
中声明的ViewController.swift
连接起来
错误发生的方式:
当我在ViewController.swift
中呼叫performSegue(withIdentifier:sender:)
时,它可以工作。
(Segue capture)
// Go to TableViewController
@IBAction func didTapNext(_ sender: Any) {
// Working
self.performSegue(withIdentifier: "viewToTableSegue", sender: nil)
}
当我在TableViewController.swift
中调用performSegue(withIdentifier:sender:)
时,出现了错误。
(Segue capture)
override func tableView(_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath) {
self.tableView.deselectRow(at: indexPath, animated: true)
// ❌ The segue `tableToCollectionSegue` is connected
// from `TableViewController` to `UICollectionViewController`,
// but got error.
//
// *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
// reason: 'Receiver (<SegueTest.TableViewController: 0x7feeea04a090>) has no segue with identifier 'tableToCollectionSegue''
self.performSegue(withIdentifier: "tableToCollectionSegue", sender: nil)
// ❌ The segue `tableToCollectionSegue` is not connected
// from `UINavigationController` to `UICollectionViewController`.
// This error is expected.
//
// *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
// reason: 'Receiver (<SegueTest.TableViewController: 0x7feeea04a090>) has no segue with identifier 'tableToCollectionSegue''
// self.navigationController?.performSegue(withIdentifier: "tableToCollectionSegue", sender: self)
}
我已阅读的内容:
我尝试过的事情:
~/Library/Developer/Xcode/DerivedData/
目录答案 0 :(得分:0)
从TableViewController
中删除以下几行:
required public init?(coder aDecoder: NSCoder) {
super.init(style: .plain)
}