1

I'm trying to call another view controller in a method of my first view controller. The view controller I'm trying to call contains a container that embeds a page view controller. Is has the storyboard ID "containerID".

I try it that way:

class loadingViewController : UIViewController {
    override func viewDidLoad() {
        var vc = self.storyboard?.instantiateViewControllerWithIdentifier("containerID") as ViewController
        self.presentViewController(vc, animated: true, completion: nil)
    }

}

And I get the error, :"whose view is not in the window hierarchy"

But I don't understand why. Could please someone help me out?

LilK3ks
  • 205
  • 2
  • 3
  • 14

1 Answers1

2

You are trying to present a view controller from a view controller who is not yet on screen. Moving this to viewDidAppear should work.

See this duplicate question: How to fix the warning: view is not in the window hierarchy

Community
  • 1
  • 1
bjtitus
  • 4,231
  • 1
  • 27
  • 35