I am creating an app for iOS and I want to open a page view controller (not a normal view controller) but only the first time that a user opens the application.
The problem is that I can't open a new page view controller within the code. The first screen that the users will see is the login screen, but on first visit switch to the page view controller.
This is what I have so far in the login screen viewcontroller:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let launchedBefore = NSUserDefaults.standardUserDefaults().boolForKey("launchedBefore")
if launchedBefore {
//Not the first time, show login screen.
}
else {
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "launchedBefore")
//First time, open a new page view controller.
}
let secondViewController:InstructionViewController = InstructionViewController()
self.presentViewController(secondViewController, animated: true, completion: nil)
}
The page view controller that I want to open is already created on the storyboard.