Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performing a Storyboard Segue programmatically

I everybody, I'm currently developing the login and password interface for a new app, and I would like to perform a segue conditionally, only when password and login are ok. I created a Segue in the Storyboard with "push" style, and "loginMainIdentifier". The implementation folder is writen as follows:

    - (IBAction)pushValidateButton:(id)sender {

    if([loginText.text isEqualToString:@""] || [passwordText.text isEqualToString:@""] )
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Identification" message:@"Veuillez completer l'ensemble des cases SVP" delegate:self cancelButtonTitle:@"Revenir" otherButtonTitles:nil];
        alert.alertViewStyle = UIAlertViewStyleDefault;
        [alert show];
    }

    if(![loginText.text isEqualToString:@""] && ![passwordText.text isEqualToString:@""])
    {
    //creation of the request
        NSMutableString *string = [[NSMutableString alloc] initWithCapacity:100];
        NSString *string01 = @"http://89.82.227.112/Vico/login.php?l=&m="; 


        [string appendFormat:string01];
        NSString *string02 = loginText.text;
        NSString *string03 = passwordText.text;

        [string insertString:string03 atIndex:41];
        [string insertString:string02 atIndex:38];

        NSURLRequest *request01=[NSURLRequest requestWithURL:[NSURL URLWithString:string]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

    //create the connection and start loading data

        NSURLConnection *connection01 = [[NSURLConnection alloc] initWithRequest:request01 delegate:self];
        if(connection01)
        {
        //Create NSMutableData to receive data
        //receiveddata is an instance declared elsewhere
        receivedData = [NSMutableData data];
        }
    }
    [self performSegueWithIdentifier:@"loginMainSegue" sender:self];
}

I dont understand why it doesn't work with [self performSegueWithIdentifier:@"loginMainSegue" sender:self] at the end of the code.

Does somebody have a clue of what is missing in order to perform segue only if login and text are filled.

Thank you

Victor

like image 237
Vico la patate Avatar asked May 03 '12 12:05

Vico la patate


People also ask

How do you do segue programmatically?

Fortunately, it only takes two steps. First, select a segue in your storyboard, then go to the attributes inspector and give it a name such as “showDetail”. Technically the sender parameter is whatever triggered the segue, but you can put whatever you want in there.

How do you make an unwind segue in a storyboard?

In your storyboard, create an unwind segue by right-clicking a triggering object and dragging to the Exit control at the top of your view controller's scene.


1 Answers

Check if the names are spelled correctly (you wrote on top loginMainIdentifier, then loginMainSegue in code).

Also check if this segue is connected from the entire viewController to, of course, the destination viewController.

like image 169
Giorgio Marziani de Paolis Avatar answered Oct 12 '22 09:10

Giorgio Marziani de Paolis