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 ?
2
Answers
AppDelegate will automatically change from LaunchScreen to window rootViewController – just place your code inside application(application: didFinishLaunchingWithOptions) method:
I’ve implement the same thing in SceneDelegate.