I have a simple application in which I'd like to display a PageViewController when a user first logs into the app. Once they have viewed the tutorial, on the next load the PageViewController doesn't display.
However I'm receiving the following message.
2017-01-24 00:20:32.620321 Infinity Toolkit[591:83298] Warning: Attempt to present <Infinity_Toolkit.PageViewController: 0x10e026000> on <Infinity_Toolkit.ViewController: 0x10dd0b030> whose view is not in the window hierarchy!
UIViewController - Default controller
override func viewWillAppear(_ animated: Bool) {
displayWalkthroughs()
}
Display Workthrough Function
func displayWalkthroughs()
{
// check if walkthroughs have been shown
let userDefaults = UserDefaults.standard
let displayedWalkthrough = userDefaults.bool(forKey: "DisplayedWalkthrough")
// if we haven't shown the walkthroughs, let's show them
if !displayedWalkthrough {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
// instantiate neew PageVC via storyboard
if let pageViewController = storyboard.instantiateViewController(withIdentifier: "PageViewController") as? PageViewController {
self.present(pageViewController, animated: true, completion: nil)
print("tried")
}
}
}
I think there is enough code to investigate there. However happy to upload more should you need it.
I don't think viewWillAppear is sufficient. I think you can only display UI after viewDidAppear has been called. Try placing your call there.