swift3 - 无法实例化 UIStoryboard(名称 : "something", bundle :nil)

标签 swift3 crash xcode8 uistoryboard

每次尝试实例化 UIStoryboard 时,都会发生致命的运行时崩溃。
这是异常中断结果的屏幕截图:

enter image description here

enter image description here

但是,如果我仅使用以下命令实例化 UIStoryboard 类,不会发生运行时崩溃: UIStoryboard();没有任何参数。

我将此代码放在 VC 的 ViewDidLoad() 中进行测试,但仍然出现运行时崩溃。

是什么导致每次都发生如此致命的事故?

<小时/> 代码如下:

 open override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        let myBundle = Bundle.main

        UIStoryboard(name: "Hamburger", bundle:myBundle)
      //   let storyboard: UIStoryboard? = UIStoryboard(name: "Hamburger", bundle: nil)

        if viewDidAppearFirstTime {
            viewDidAppearFirstTime = false
            configureAttributesViewer()
        }
    }

最佳答案

我尝试了您想要的示例,当我运行该应用程序时它运行良好,也没有显示任何错误。请找到以下步骤。

let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let Hamburger = storyBoard.instantiateViewController(withIdentifier: "Hamburger")
self.navigationController?.pushViewController(Hamburger, animated:true)

关于swift3 - 无法实例化 UIStoryboard(名称 : "something", bundle :nil),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44292526/

相关文章:

c++ - 反转for循环导致系统错误

swift - 使用 XCode 进行测试时,MacOS 应用程序本地通知不显示

ios - 按钮在 UIDocumentPickerViewController 中不可见

ios - Completion Block 在 Swift 3 中变为 nil

VBA 应用程序崩溃且没有错误消息 - 单步执行程序时有效

C fscanf 从文件错误中读取数据

ios - 推送通知不适用于 testflight 和 xcode 8 beta

sqlite - GRDB.swift 使用 swift 3 请求而不通过模型[完成]

swift - SigQuit 在 Swift 3、Xcode 8.2.1 中的含义

ios - Xcode 8 beta 6 中的 Swift header 问题