1

I have an app having 7 screen. On the screen 7 i have a button that does valiation and submits data and then it jumps to screen 1 using modal segue. But ,I only want to move screen1 if the validation succeeds or else i dont want to move to screen1. Currently its moving to screen 1 independent of validation.

button click code is as below

- (IBAction)submitButtonActionForDemo:(id)sender
{
    if (![JLTValidator validateFields:@[_authRepresentative, _acceptDeclarationStatement,_homeTeamRepName,_homeTeamRepPosition,_awayTeamRepName,_awayTeamRepPosition]])
    {
       // how to disable a modal segue here.
        return; 
    }
}

JLTValidator is my validating class here.

Pls suggest/help. Thanks in adv.

Lalit_vicky
  • 295
  • 1
  • 5
  • 15

1 Answers1

2

If you want to only allow the segue some times, you need to "name" the segue in InterfaceBuilder, then implement this routine:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
    if ([identifier isEqualToString:@"your segue name"]) {
        return false;
    }
    return true;
}
HalR
  • 11,411
  • 5
  • 48
  • 80