gpt4 book ai didi

ios - 从 AppDelegate 加载屏幕

转载 作者:行者123 更新时间:2023-11-30 12:14:50 26 4
gpt4 key购买 nike

在点击我的应用程序的深层链接后,我尝试从 AppDelegate 加载屏幕。不幸的是它使我的应用程序崩溃了。

我使用此代码尝试呈现 UI:

self.window = UIWindow(frame: UIScreen.main.bounds)
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let bestViewController: BestViewController = mainStoryboard.instantiateViewController(withIdentifier: "BestViewController") as! BestViewController
bestViewController.selectedBrocode = result
let navigationViewController = BroNavigationViewController(rootViewController: bestViewController)
self.window?.rootViewController = navigationViewController

这在我的控制台中打印:

2017-08-08 16:00:48.685 BroCode[17567] <Warning> [Firebase/Analytics][I-ACS031011] Root view controller not found
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-08-08 16:00:48.687130+0800 BroCode[17567:6659940] fatal error: unexpectedly found nil while unwrapping an Optional value

这是堆栈跟踪:

libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
0x1012ec3d0 <+0>: stp x26, x25, [sp, #-0x50]!
0x1012ec3d4 <+4>: stp x24, x23, [sp, #0x10]
0x1012ec3d8 <+8>: stp x22, x21, [sp, #0x20]
0x1012ec3dc <+12>: stp x20, x19, [sp, #0x30]
0x1012ec3e0 <+16>: stp x29, x30, [sp, #0x40]
0x1012ec3e4 <+20>: add x29, sp, #0x40 ; =0x40
0x1012ec3e8 <+24>: mov x19, x6
0x1012ec3ec <+28>: mov x20, x5
0x1012ec3f0 <+32>: mov x21, x4
0x1012ec3f4 <+36>: mov x22, x3
0x1012ec3f8 <+40>: mov x23, x2
0x1012ec3fc <+44>: mov x24, x1
0x1012ec400 <+48>: mov x25, x0
0x1012ec404 <+52>: adr x8, #0xf11fc ; protocol descriptor for Swift._DefaultCustomPlaygroundQuickLookable + 136
0x1012ec408 <+56>: nop
0x1012ec40c <+60>: add x0, x8, #0x10 ; =0x10
0x1012ec410 <+64>: mov w1, #0x28
0x1012ec414 <+68>: orr w2, wzr, #0x7
0x1012ec418 <+72>: bl 0x1012ec750 ; swift_rt_swift_allocObject
0x1012ec41c <+76>: mov x8, x0
0x1012ec420 <+80>: stp x22, x21, [x8, #0x10]
0x1012ec424 <+84>: strb w20, [x8, #0x20]
0x1012ec428 <+88>: str w19, [x8, #0x24]
0x1012ec42c <+92>: adr x3, #0x40440 ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
0x1012ec430 <+96>: nop
0x1012ec434 <+100>: mov x0, x25
0x1012ec438 <+104>: mov x1, x24
0x1012ec43c <+108>: mov x2, x23
0x1012ec440 <+112>: mov x4, x8
0x1012ec444 <+116>: bl 0x1011cd4dc ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to @callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (@out ()), Argument Types : [@callee_owned (@unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
-> 0x1012ec448 <+120>: brk #0x1

屏幕截图:

enter image description here

最佳答案

请检查storyboard中的Storyboard ID是否为BestViewController。

enter image description here

也请尝试注释掉

bestViewController.selectedBrocode = result

关于ios - 从 AppDelegate 加载屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45562610/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com