shouldPerformSegueWithIdentifier issue

99封情书 提交于 2019-12-01 13:59:24

When pressing login button do run the code

if (![emailTxt.text isEqualToString:@""] &&
    ![passwordTxt.text isEqualToString:@""]){
    Login *loginModel = [[Login alloc]init];
    loginModel.emailAddr =emailTxt.text;
    loginModel.password = passwordTxt.text;
    [ASKevrOperationManager login:loginModel handler:^(id object , NSError *error , 
    BOOL success)
     {
         if (success){
             NSLog(@"object =%@",object);
             NSDictionary *arr = [object objectForKey:@"response"];
             str = [arr objectForKey:@"flag"];
             //check for error
                 NSDictionary *toDict = [object objectForKey:@"response"];
                 currentUserId = [toDict objectForKey:@"c_id"];
                 NSLog(@"currentUserId = %@",currentUserId);

            //perform the segue only when succesful
            [self performSegueWithIdentifier:@"yourSegue" sender:sender];
         }else{
            [self showAlertWithMessage:@"Wrong Id or Password."];
         }
     }];    
}else {
    [self showAlertWithMessage:@"Please write your id or password"];
}

Keep your shouldPerformSegueWithIdentifier simple

-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
   if ([identifier isEqualToString:@"pushTab"])
   {
        //don't put logic here
        //put code here only if you need to pass data
        //to the next screen
        return YES:
   }
   return NO;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!