To stop segue and show alert

后端 未结 3 605
南旧
南旧 2020-12-04 16:50

Using iOS 5 storyboards, on a button I am performing a segue, what I want is to do validation on my textfield and if validation is failed I have to stop segue and throw an a

3条回答
  •  自闭症患者
    2020-12-04 17:29

    I'll give you an example, here's my code:

    - (IBAction)Authentificate:(id)sender {
    if([self WSAuthentification]){
       [self performSegueWithIdentifier:@"authentificationSegue" sender:sender];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Authetification Failed" message:@"Please check your Identifications" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
        [alert show];
    }
    

    But it seems that's not working, in all cases my segue is performed. The answer is easy, we have to wire the segue from the view controller it self not from the Button.

提交回复
热议问题