Why doesn't performSegueWithIdentifier work inside viewDidLoad?

ios, ios5, objective-c, xcode

Solution

You can not dismiss a view controller that isn't presented yet. `didLoad` has purely memory management functions, you can use it as (part of a) constructor. What may work, is to start a segue in `viewDidAppear`, however I would suggest to start with the view you want at the first time.

Problem

I'm trying to trigger a storyboard segue as soon as viewDidLoad is called on a view controller. The segue has an identifier attached, and works fine when called from inside a method thats linked to a button or other control. But it doesn't work inside of viewDidLoad. It just silently fails. Is there some rule about segue's being ignored in viewDidLoad? I've tried both this: ``` [self performSegueWithIdentifier: @"mySegue" sender: self]; ``` and this: ``` [self dismissViewControllerAnimated:YES completion:^() { [self performSegueWithIdentifier:@"mySegue" sender:self]; }]; ``` Neither work.

Original source