即使登录信息不正确,登录页面仍会进入主UITabBar视图 [英] Login page goes to main UITabBar view even with incorrect login info

查看:79
本文介绍了即使登录信息不正确,登录页面仍会进入主UITabBar视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我已链接到服务器,并且我知道我所有的代码正确.但是这段代码似乎有问题:

Ok so I'm linked to a server and I know for a fact that I have all the code there correct. But something seems to be wrong with this code:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
    NSString* responseString = [[NSString alloc] initWithData:_responseData encoding:NSUTF8StringEncoding];

    /*Succesful Login*/
    if([responseString isEqualToString:@"success"]){

        [self performSegueWithIdentifier:@"LoginHomeToMain" sender:self];

        NSLog(@"Succesful login.");
    }

    /*Deactivated Account*/
    else if([responseString isEqualToString:@"disabled account"]){

    }

    /*Incorrect username and password.*/
    else if([responseString isEqualToString:@"incorrect"]){
        NSLog(@"Incorrect username and (or) password.");
    }

    /*GET request*/
    else if([responseString isEqualToString:@"get"]){

    }
}

所以我认为您可以忽略第二和第四,如果是,但这是问题所在: 当我尝试用户并传递我所知道的服务器中不存在的用户时,它仍会搜索我到主选项卡栏视图.我是否应该为不正确"的逻辑重新加载登录页面的视图,还是我的查询错误? P.S. segue只需从登录按钮链接到主标签栏视图即可,并且是模态的.

So I think you can ignore the 2nd and 4th else if's but here's the problem: When I try a user and pass that I know does not exist in the server, it still segues me to the main tab bar view. Am I supposed to reload the login page's view for the "incorrect" logic, or is my segue wrong? P.S. The segue is simply linked from a login button to the main tab bar view, and is modal.

此外,我一直在调试器中收到此错误消息:

Also, I keep getting this error message in the debugger:

不平衡的呼叫开始/结束外观转换."

非常感谢您的帮助,谢谢!

Any help is greatly appreciated, Thanks!

推荐答案

如果要有条件地执行segue,则需要将segue从源视图控制器链接到目标视图控制器.

If you want to perform a segue conditionally, you need to link the segue from the origin view controller to the destination view controller.

请勿通过按钮之类的UI元素链接segue. (如果您只想有条件地执行segue,则是

从按钮到视图控制器更改segue的原始连接将解决您的问题,而无需更改代码行.

Changing your segue's origin connection from the button to the view controller will fix your problem without changing a line of code.

就我个人而言,我刚开始总是从视图控制器进行链接.只需编写一行代码即可执行segue,这很容易,而且您永远都不知道何时需要在其后编写某种条件逻辑.因此,养成这样的习惯可能很好.

Personally, I've just started always linking from view controller. It's easy enough to write the one line of code to perform the segue, and you never know when you'll have to write some sort of conditional logic around it later. So it's probably good to just get into the habit of doing it this way.

这篇关于即使登录信息不正确,登录页面仍会进入主UITabBar视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆