我有一个带有提交按钮的用户登录页面,成功登录后我想转到下一个视图。为此,我正在调用 Web 服务(这将验证来自后端数据库的数据),它将根据成功或失败返回 true 或 false .这工作正常;也就是说,我能够使用 NSXMLParser 获得价值,如下所示:
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if (elementFound) {
soapResults = [string boolValue];
//NSLog(@"soapResultss = %@",soapResults);
}
if (soapResults)
{
x = 1; // x is 1 if username and password are correct.
}
else
{
x = 0;//x is 0 if username and password are incorrect
}
}
同时(成功时)我试图在我的“提交按钮点击”方法中调用下一个视图:
if(x==0)
{
}
else if(x==1)
{
[self.navigationController pushViewController:self.viewController animated:YES];
}
但是,问题是,控件没有回到“提交按钮单击”,即“else if”部分。而且,我认为这不是正确的做法。正确的做法是什么? 请建议。谢谢。