Reputation: 25
When the application comes out of the background, it is necessary that the LaunchScreen is loaded after returning to the application.
Is it possible to somehow open the Launch screen through applicationWillEnterForeground(_:)
?
I tried to do through UIApplicationExitsOnSuspend
- in iOS 13 Deprecated
Upvotes: 0
Views: 126
Reputation: 5644
If I understood correctly, you can display the launch screen like this:
func applicationWillResignActive(_ application: UIApplication) {
let controller = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()!
if let navigationController = self.window?.rootViewController as? UINavigationController
{
navigationController.pushViewController(controller, animated: false)
}
}
func applicationDidBecomeActive(_ application: UIApplication) {
if let navigationController = self.window?.rootViewController as? UINavigationController
{
navigationController.popViewController(animated: false)
}
}
Have to be a NavigationController in Main.storyboard
Upvotes: 1