gpt4 book ai didi

swift - 添加新的 View Controller B 并将其更改为初始 View Controller 后出现 "View Controller A unreachable because it has no entry points"错误

转载 作者:行者123 更新时间:2023-11-30 10:27:49 26 4
gpt4 key购买 nike

这个错误似乎很常见,但我似乎找不到与我的错误类似的根本原因,因此解决方案不起作用。

最初,我的应用程序中只有一个 View Controller (VC 1),嵌入导航 Controller (NC) 中。

然后我添加了第二个 VC 2 并从 VC 1 中删除了 NC。然后我将 VC 2 嵌入到 NC 中并使其成为初始 View Controller 。

VC 2 是一个 TableView Controller ,当点击单元格时:

  • 实例化 VC 1,
  • 更改变量,并且
  • 使用navigationController推送VC 2

VC 2 包含一个完成大部分工作的 webView。

设置完所有这些后,我得到了一个断点和一个警告:

“View Controller“ is unreachable because it has no entry points, and no identifier for runtime access via -[UIStoryboard instantiateViewControllerWithIdentifier:].

我在 VC 1 中添加了一个新的 NC,以为这可以解决问题,但事实并非如此。刚刚更改为

“Navigation Controller“ is unreachable because it has no entry points, and no identifier for runtime access via -[UIStoryboard instantiateViewControllerWithIdentifier:].

不确定这是否是足够的信息,但是这里是否有潜在的明确解决方案?

编辑:在 VC 2 中添加 didSelectRowAt 函数,将您带到 VC 1,以防有帮助:

    override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
if let vc = storyboard?.instantiateViewController(withIdentifier: "Browser") as? ViewController {
vc.selectedWebsite = websites[indexPath.row]
vc.approvedWebsites = websites
navigationController?.pushViewController(vc, animated: true)
}
}

最佳答案

在 Storyboard 中选择 View Controller ,然后选择右 Pane 中的 Identity Inspector,并将 Identity -> Storyboard ID 设置为“浏览器”

关于swift - 添加新的 View Controller B 并将其更改为初始 View Controller 后出现 "View Controller A unreachable because it has no entry points"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59779639/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com