Reputation: 574
i've searched a solution but nothing.
My problem:
In AppDelegate
i call:
window = UIWindow(frame: UIScreen.mainScreen().bounds)
var vc = ViewController()
self.window.rootViewController = vc
window.makeKeyAndVisible()
I need to call ViewController()
where, in ViewDidLoad
, i evaluate if the user is logged, then if yes i call an view controller (not implemented yet), otherwise i call AccessLoginViewController()
in this mode:
let vc = AccessLoginViewController()
self.presentViewController(vc, animated: true, completion: nil)
and there i've then warning and AccessLoginViewController() does not appear...
Can you help me? What's wrong?
Upvotes: 0
Views: 1347
Reputation: 17958
Until you call makeKeyAndVisible
the entire window might not be in the view hierarchy, including the controller it contains. Instead of performing this check in viewDidLoad
it sounds like something better suited to viewWillAppear:
which I would expect to solve your immediate problem (you may have to account for the fact that a controllers view may appear many times during its life).
Upvotes: 0