Reputation: 3298
I have given my segue the identity modaltomenu
in my code I am calling the segue with the following:
if([login_status isEqualToString:@"success"]){
//start the menuviewcontroller
[self performSegueWithIdentifier:@"modaltomenu" sender:self];
NSLog(@"segue %@", @"performed");
}
the if statement is always true.
However the second view is never loaded. This code is ran when the first view loads.
Why isnt my segue loading?
Thanks!
Upvotes: 0
Views: 5366
Reputation:
You said the code is ran when the first view loads so am I right in assuming its in the viewDidLoad method? If so, try moving that if statement to the viewDidAppear method in the view controller life cycle. ViewDidLoad usually only happens once, whereas viewDidAppear is called every time the view appears on screen. So it would look like...
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:YES];
if([login_status isEqualToString:@"success"]){
//start the menuviewcontroller
[self performSegueWithIdentifier:@"modaltomenu" sender:self];
NSLog(@"segue %@", @"performed");
}
}
Upvotes: 1
Reputation: 14427
To troubleshoot further, put this in that VC:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"segue identififer = %@",segue.identifier);
}
And make sure that your code in viewDidLoad
is executing as expected. If it doesn't, you might want to re-think where you call that performSegue
method.
Upvotes: 1