Bogdan Pop
Bogdan Pop

Reputation: 438

performSegueWithIdentifier and viewDidLoad

MainViewController:

[self performSegueWithIdentifier:@"showNextVC sender:self];

Segue destination controller:

- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"Show text!");
[self performSegueWithIdentifier:@"showSignUp" sender:self]; }

Why doesn't the code from the destination controller's viewDidLoad method execute?

Upvotes: 3

Views: 4479

Answers (2)

user4254887
user4254887

Reputation:

if you copied and pasted I'd assume it's because you're missing a " which the compiler should've warned you about

if the " is there try an NSLog in your prepare for segue and see if it's getting called

Upvotes: 0

PKP
PKP

Reputation: 194

viewDidLoad is called when the ViewController object is created loading nib file. It is not yet attached to the window. You should call performSegue... call in viewDidAppear.

Finally, If you are calling performSegue directly without any action being performed. I'd suggest you take a look at the flow again.

Upvotes: 13

Related Questions