I am trying to call a segue in my iOS app but am getting the error
Could not find a navigation controller for segue ___
I determined that the issue is that when I try to check the current visibleViewController, it is not the ViewController that the segue is linked to:
if(self.navigationController.visibleViewController == self){
[self performSegueWithIdentifier:@"login_success" sender:self];
}else{
NSLog(@"LoginViewController is not currently visible");
}
My question is, how can I set the correct view controller so I can call the segue?
Here is all my code:
LoginViewController: (The first ViewController)
-(IBAction)registerClick:(id)sender{
// open up registration
[self performSegueWithIdentifier:@"registration" sender:self];
}
Registration ViewController (the Modal ViewController)
-(IBAction)finish:(id)sender{
// return back to login view controller
[self dismissViewControllerAnimated:YES completion:nil];
}
LoginViewController segue attempt:
if(self.navigationController.visibleViewController == self){
[self performSegueWithIdentifier:@"login_success" sender:self];
}else{
NSLog(@"LoginViewController is not currently visible");
}