【发布时间】:2017-05-31 18:46:46
【问题描述】:
每次我尝试实例化 UIStoryboard 时都会遇到致命的运行时崩溃。
这是异常中断结果的屏幕截图:
但是,如果我仅使用以下命令实例化 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()
}
}
【问题讨论】:
-
你为什么尝试使用 UIStoryboard(name: "Hamburger", bundle:myBundle) 这一行?
-
UIStoryboard(...) 崩溃了。我对结果不感兴趣,只是想看看 UIStoryboard 是否会运行而不会崩溃。
标签: swift3 crash xcode8 uistoryboard