I made a ViewController that displays every time the app enters te foreground. This is because I want the user to authenticate every time the app enters the foreground (like bank apps do). I made this functionality this way:
func applicationDidEnterBackground(_ application: UIApplication) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "localauth")
self.window!.rootViewController = controller;
self.window!.makeKeyAndVisible();
}
self.window! is a property of AppDelegate.swift. I added this myself. I'm not sure this is the way to go:
var window: UIWindow?
This function in the AppDelegate switches the current ViewController to the Auth ViewController when the app enters the background. So when the app enters the foreground again, the "localAuth" ViewController is shown.
When the user is authenticated, the ViewController that handles the authentication shows the next ViewController:
self.performSegue(withIdentifier: "localAuthed", sender: self);
The LocalAuth ViewController is connected with the next ViewController in the storyboard by a segue named localAuthed. The next ViewController is a NavigationController, so it displays the first ViewController that is embedded in that NavigationController.
Now here is what happens. The right embedded ViewController is shown, but the title of the actionbar is missing. When I wait a while, the title appears.
Is the way I present ViewControllers the right way?