有两个UITextField,我想要检测UITextField,当满足两个UITextField都有文本内容时,显示alert,如果只有一个UITextField有文本内容时向下一步进行。
if([txt1.text length] > 0 && [txt2.text length]>0)
{
UIAlertView * alert=[ [UIAlertView alloc]initWithTitle:@"Alert" message:@"TextFied Have an Text" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
[alert show];
}
else
{
//Go Forword
}
执行 UITextField 代理:
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if ([textField1.text length] > 0 && [textField2.text length] > 0)
{
UIAlertView *alert = [ [UIAlertView alloc]initWithTitle:@"" message:@"Hello" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
else
{
// go forward here.....
}
}