PresentViewController: animated: NO briefly showing the controller view in iOS 8. Alternatives?

Usually, when you start the application, the basic structure of the user interface is created, but if the user is not logged in during the launch of the application, a modal input / login screen above the regular user interface immediately appears.

Usually presentViewController:animated:NO was available to display the modal user interface, because the user would see: App Launch Image β†’ Login UI.

However, on iOS 8, it seems that calling presentViewController with animated = NO still briefly shows the underlying view controller for the frame before the view controller's view.

Example:

BVy9gQS.gif

I do not want to enter the user interface first, because when the user is logged in, I would introduce the main user interface from the login user interface, thereby supporting the login interface unlimitedly.

Is there any other way that I have not considered? Can storyboards help me here?

+5
source share
3 answers

Personally, I check the login status at application startup, and then install the login controller or the main root view controller as the root window view controller.

When a user logs in or logs out, the window root window controller is replaced. It can be animated. I think this approach is completely clean.

+2
source

I assume that the problem will disappear if you use storyboards and do not program an instance of your initial or logical controllers. UIKit seems to work best when you just let it do its job ...

Here's how to conditionally invoke a login controller using a storyboard:

fooobar.com/questions/1206273 / ...

+1
source

I don’t know what your exact usecase is, but in my application the user can be logged out at any time, no matter which view controller it is at that time. I need to present the login screen and give the user the opportunity to log back in and return the user to where he was if the login was successful.

What all this means is that I cannot force the root login controller and stack other controllers on top of it, because I cannot just disable them if the user logs out.

However, I can save the VC stack and go to the login screen and then return to the main VC stack when the login is successful.

 class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var primaryViewController: UIViewController? var loginViewController: UIViewController? func userLoggedOut() { self.window?.rootViewController = loginViewController } func userLoggedIn() { self.window?.rootViewController = primaryViewController } func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // other setup code let storyboard = UIStoryboard(name: "Main", bundle: nil) loginViewController = storyboard.instantiateViewControllerWithIdentifier("LoginViewController") as? UIViewController primaryViewController = self.window?.rootViewController if (!currentlyLoggedIn) { userLoggedOut() } return true } 
+1
source

Source: https://habr.com/ru/post/1206272/


All Articles