swift - 在Xcode 11.3 ViewController中崩溃

标签 swift crash xcode11.3

获取错误::由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'从-traitCollection返回nil,这是不允许的。

这种方法崩溃了func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController { let sb = UIStoryboard.init(name: storybordname, bundle: nil) var viewcontroller:UIViewController! viewcontroller = sb.instantiateViewController(withIdentifier: controllername) return viewcontroller }当我在放置断点后检查时,其崩溃在第一行super.viewDidLoad()

最佳答案

将您的viewdidload代码放入disptachQueue

DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
               // Your Code
  })

像这样...

关于swift - 在Xcode 11.3 ViewController中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60717252/

相关文章:

arrays - 无法将类型 'Meme!' 的值转换为预期的参数类型 '@noescape (Meme) throws -> Bool'

python - Pygame 一段时间后无法从资源中读取

ios - UIApplicationMain 的 EXC_BAD_ACCESS - 如何解释此回溯?

swift - Xcode 11.3.1中SceneKit中的粒子系统文件在哪里

memory-management - Swift 5 - 模拟器启动时显示白屏 - 仪器

ios - Xcode 无法为 ios 13.3.1 设备构建 flutter 代码,但在 13.3 ios 模拟器上运行代码

ios - 如何去除图像的噪点?

swift - 为什么按下后退按钮后导航 Controller 中的 View 会清晰?

java - 在操作栏上按 "back"时 Android 应用程序崩溃

ios - Swift - 将来自 API 的数据传递到另一个 View Controller