Search code examples
iosobjective-cviewdidload

Link to another ViewController inside viewDidLoad method


in the viewDidLoad method i have this code. When the application is running its not go to the another viewController, its gives me an error:

Warning: Attempt to present <CompleteCountryViewController: 0x7fb971779be0> on <ViewController: 0x7fb97176f3e0> whose view is not in the window hierarchy!

What can i do, that when the application running its will go to another viewController?


Solution

  • You should not present a view controller in the viewDidLoad method of another controller because you cannot show a view controller (present modally or push) when a transition is already occurring (push, pop, present, dismiss).

    My suggestion is that you move the code in your code sample to the viewDidAppear: method. At this point, you know for sure that the transition has completed.