You can do this by adding the following code to your code
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { if([identifier isEqualToString:@"btnSegue"]) { return YES; } else{ return NO; } }
Let's assume your segue is btnSegue. And if you need to execute segue based on some condition, you can have the following code
if(check) { [self performSegueWithIdentifier:@"btnSegue" sender:self]; }
Where's the BOOL check that you can set to true or false based on your condition.
source share