I have an app that consists of a sign up and login view controller. Once users have signed up or logged in, they are segued to the main view controller. I've implemented NSUserDefaults
to store a boolean value of the users login status, so that when they reopen the app they are automatically segued to the main view controller rather than having to go through the login view controller. I'm checking the users login status in didFinishLaunchingWithOptions
and if the login status stored in NSUserDefaults
is true, I initiate the segue to the main vc.
I'm currently using the code below to present the main view controller:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier :"Recorder") as! RecordController
let navController = UINavigationController.init(rootViewController: viewController)
if let window = self.window, let rootViewController = window.rootViewController
{
var currentController = rootViewController
while let presentedController = currentController.presentedViewController
{
currentController = presentedController
}
currentController.present(navController, animated: true, completion: nil)
}
The problem with this is that I don't want my main view controller to be my root view controller and presenting the main view controller is creating some weird vertical spacing that I can't figure out - might be some issue with the navigation controller.