“ View Controller A无法访问,因为它没有入口点”,在添加新的View Controller B并将其更改为初始View Controller后出现错误

问题描述 投票:0回答:1

此错误似乎很常见,但我似乎找不到与我类似的根本原因,因此解决方案无法正常工作。

我最初在我的应用中有一个View Controller(VC 1),嵌入在导航控制器(NC)中。

然后我添加了第二个VC 2,并从VC 1中删除了NC。然后,我将VC 2嵌入了NC中,并使其成为初始视图控制器。

VC 2是一个表视图控制器,当点击一个单元格时:

  • 实例化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)
        }
    }
swift storyboard runtime navigationcontroller
1个回答
0
投票

在情节提要中选择视图控制器,然后在右窗格中选择Identity Inspector并将Identity -> Storyboard ID设置为“浏览器”

© www.soinside.com 2019 - 2024. All rights reserved.