繁体   English   中英

找不到在捆绑 NSBundle 中命名的故事板

[英]Could not find a storyboard named in bundle NSBundle

我正在创建一个带有故事板实例的 pod,当我尝试启动我的应用程序时遇到了问题,我需要有人来解决这个问题,我已经尝试了所有方法,但仍然遇到了同样的问题,我遇到了这个错误:

应用因未捕获的异常 'NSInvalidArgumentException',理由是: '找不到一个名为情节串连图板 '的' 捆绑一个NSBundle(加载)' ***第一掷调用堆栈:(0x1a0d1d27c 0x19fef79f8 0x1cd7e3350 0x102ea1700 0x102eac088 0x102eac018 0x103090c74 0x103092c84 0x1cf08ee40 0x102eac1b0 0x102b1e414 0x102b1e610 0x1cd30fd40 0x1ab3a1f28 0x1ab341304 0x1cd3142ac 0x1ab3a1f28 0x1ab3a216c 0x1ab341304 0x1cd311b94 0x1cd7e39a4 0x1cd657150 0x1cd6575d0 0x1cd655c34 0x1ccf192dc 0x1ccf21874 0x1ccf18f60 0x1ccf19850 0x1ccf17b9c 0x1ccf17864 0x1ccf1c3a4 0x1ccf1d188 0x1ccf1c25c 0x1ccf20f5c 0x1cd654328 0x1cd250ba8 0x1a36989fc 0x1a36a240c 0x1a36a1c14 0x103090c74 0x103094840 0x1a36d3040 0x1a36d2cdc 0x1a36d3294 0x1a0caf018 0x1a0caef98 0x1a0cae880 0x1a0ca97bc 0x1a0ca90b0 0x1a2ea979c 0x1cd657978 0x102b20f50 0x1a076e8e0)的libc ++ abi.dylib:与未捕获的终止NSException 类型的异常

我的故事板分享方法我的代码:

public static var share: ChatKit = {
    let storyboard = UIStoryboard(name: "ChatKit", bundle: nil)
    return storyboard.instantiateViewController(withIdentifier: "ChatKit") as! ChatKit
}()

由于您可能在 CocoaPod 中,因此故事板将不在主包中。 这是因为 Storyboard 被添加到 CocoaPod 资源包中(可能你可以在你的 .podspec 中看到这一点)。 最好通过这个 bundle 而不是 nil:

Bundle(for: SomeClass.self)

SomeClass 在您的 Pod 中的位置。

这个问题也可能对你有帮助: How to load resource in cocoapods resource_bundle

让 bundle = Bundle(for: YourBundleName.self)

bundle.loadNibNamed(NibFileName, owner: self, options: nil)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM