【发布时间】:2014-07-20 10:48:55
【问题描述】:
我搜索了网络但没有找到答案。 在我的应用中,我有一个用户注册,所以我必须在接受用户之前检查输入文本字段。
这是我的代码:
- (IBAction)continueRegister:(id)sender {
if (!termsOfUseChecked)
NSLog(@"Error");
else
NSLog(@"Success");
if ([_regTelephoneNumber.text length] > 10) {
[self initWithTitle:@"error" andMessage:@"bla bla" andCancelButton:@"ok"];
}
if ([_regUserEmail.text rangeOfString:@"@"].location == NSNotFound){
[self initWithTitle:@"error" andMessage:@"bla bla" andCancelButton:@"ok"];
}
if (![_regPassword.text isEqualToString:_regConfirmPassword.text]) {
[self initWithTitle:@"error" andMessage:@"bla bla" andCancelButton:@"ok"];
}
}
-(void)initWithTitle:(NSString*)title andMessage:(NSString*)message andCancelButton:(NSString*)cancelButton;
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:title message:message delegate:self cancelButtonTitle:cancelButton otherButtonTitles:nil, nil];
[alert show];
}
但如果发生多个错误,用户会收到很多弹出窗口。 有什么方法可以在同一个 UIAlertview 中显示所有错误?
【问题讨论】:
标签: ios objective-c uialertview uialertviewdelegate