【发布时间】:2015-10-29 21:02:45
【问题描述】:
我正在尝试为应用构建登录页面。测试登录条件时出现问题。
有两个文本字段,username 和 password。单击登录按钮时,警报会在
1) 任一字段为空 2) 两个都填满。
代码反映了这一点。但是无论文本字段是否为空,结果都会出现,它仅显示为文本字段已填充(仅运行 else 部分)。所以我认为 if 条件有问题。但是当我在其他视图中检查 if 条件时,它起作用了。
谁能帮忙?
if ([_pLoginIDField.text isEqualToString:@""] || [_pPasswordField.text isEqualToString:@""]) {
UIAlertView *error = [[UIAlertView alloc] initWithTitle:@"Yeah !" message:@"must complete all fields" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[error show];
}
else {
UIAlertView *error2 = [[UIAlertView alloc] initWithTitle:@"Oooops !" message:@"hhhhhhhhhh" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[error2 show];
}
【问题讨论】:
-
如果你在
if之前同时NSLog和UITextView.text,结果是什么?
标签: ios objective-c cocoa-touch uitextfield