启动屏幕出现后,Uikit自动切换到另一个VC
我正在尝试在3秒后自动从Lauch屏幕切换到主屏幕。 这是入口点视图控制器中的代码
override func viewDidAppear(_ animated: Bool) {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) {
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = enter code heremainStoryboard.instantiateViewController(withIdentifier: "GenresNC")
UIApplication.shared.windows.first?.rootViewController = screen
self.view.window?.makeKeyAndVisible()
}
}
。 线程1:exc_bad_access(代码= 2,地址= 0x16f5c7de8)
有人可以帮忙吗?
I'm trying to automatically switch from lauch screen to home screen after 3 sec.
This is code in entry point view controller
override func viewDidAppear(_ animated: Bool) {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) {
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = enter code heremainStoryboard.instantiateViewController(withIdentifier: "GenresNC")
UIApplication.shared.windows.first?.rootViewController = screen
self.view.window?.makeKeyAndVisible()
}
}
It brakes at line with mainStoryboard...
Thread 1: EXC_BAD_ACCESS (code=2, address=0x16f5c7de8)
Can somebody help ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AppDelegate将自动从启动屏幕更改为window rootviewController-只需将代码放置在应用程序中(应用程序:didfinishlaunchingwithoptions)方法:
AppDelegate will automatically change from LaunchScreen to window rootViewController - just place your code inside application(application: didFinishLaunchingWithOptions) method:
我已经在SceneDelegate中实现了同样的事情。
I've implement the same thing in SceneDelegate.