I understand that it is not allowed and UISplitViewController should always be root controller.
How can I have a login screen before splitViewController? It seems to be a very common problem.
I am new to iOS so any example will be much appreciated.
Tried updating viewDidLoad() of MasterViewController:
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
if (!appDelegate.loggedIn) {
// display the login form
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let login = storyboard.instantiateViewControllerWithIdentifier("LoginVC") as UIViewController
self.presentViewController(login, animated: false, completion: { () -> Void in
// user logged in and is valid now
//self.updateDisplay()
})
} else {
//updateDisplay()
}
But it threw me a warning: arning: Attempt to present <LoginViewController: 0x7f8ef8f12c80> on <SideBarViewController: 0x7f8ef8d9faf0> whose view is not in the window hierarchy!
Make your initial view controller the split view controller. In its viewDidLoad
or viewDidAppear
methods or whatever makes sense, check that the user is logged in. If the user isn't logged in, segue modally WITHOUT animation to your login view controller. This will all happen without the user noticing and will allow the storyboard setup you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.