【发布时间】:2019-09-17 15:35:28
【问题描述】:
事情是这样的:我的故事板是一个 SettingViewController(以 SVC 命名)和一个 StationsViewcontroller,后者通过“openDetails”segue 连接到细节视图控制器。
出于实际原因,我的 SVC 可以推送多个级别的具体设置视图控制器,我没有在情节提要中定义。
在某一时刻,其中一个 vc 推送了 StationsViewController,然后它可以向细节发出 performSegue:不幸的是,我得到“openDetails”segue 没有定义。
我应该怎么做才能解决这个问题?
--
代码没什么特别的,在SettingsViewController中,我推送其他VC,包括StationsViewController:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Gracefully remove the selection
tableView.deselectRow(at: indexPath, animated: true)
guard let section = MainSections(rawValue: indexPath.section) else { return }
switch section {
case .stations:
let vc = StationsViewController()
// Do no segue at dismiss
vc.onlyDismiss = true
vc.didDismiss = {
self.navigationController?.popViewController(animated: true)
}
push(vc, hideNavigation: true)
// Blah blah
在我想要获取详细信息 vc 的 StationsViewController 中,我执行 segue:
func openPoiDetails(_ gs: GasStation) {
poiDetails = gs
performSegue(withIdentifier: "poiDetails", sender: nil)
// Blah blah
故事板如下,我们可以看到左侧的 StationsViewController 通过“openDetails”segue 连接到 details vc:
【问题讨论】: