gpt4 book ai didi

iphone - 如何设置文本字段的条件。文本?

转载 作者:行者123 更新时间:2023-12-03 20:53:55 27 4
gpt4 key购买 nike

if([txtField1.text  intValue] == nil  && [txtField2.text  intValue] == nil && [txtField3.text  intValue] == nil  && [txtField4.text  intValue] == nil  && [txtField5.text  intValue] == nil && [txtField6.text  intValue] == nil && [txtField7.text  intValue] == nil && [txtField8.text  intValue] == nil )
{
UIAlertView *info = [[UIAlertView alloc] initWithTitle:@"Info" message: @"Please complete your test." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[info show];
[info release];

}
else if(txtField1.text == NULL || txtField2.text == NULL || txtField3.text == NULL || txtField4.text == NULL || txtField5.text == NULL || txtField6.text == NULL ||txtField7.text == NULL || txtField8.text == NULL )
{
UIAlertView *info = [[UIAlertView alloc] initWithTitle:@"Info" message: @"Please complete your test." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[info show];
[info release];

}
else{
fourthScreen=[[FourthScreen alloc] initWithNibName:@"FourthScreen" bundle:nil];
[self.navigationController pushViewController:self.fourthScreen animated:YES];
}

在上面的代码中我有 8 个文本字段。为此,我定义了一个条件,即当所有文本字段均为空白或 nil 时,显示警报 View 消息。它正在发挥作用。但是,当我定义为当任何一个文本字段为零或空白时,也会显示警报 View ,但不会显示。问题是,当我输入整数值“0”时,它也会显示警报 View ,但我希望它不显示“0”值。 picke4r View 选择的值。如何设置代码?

最佳答案

尝试:

if([txtName.text length] == 0 || [txtName.text isEqualToString:@""])
{
// Alert here
}

测试长度为 0 或将字符串与空白字符串进行比较。

关于iphone - 如何设置文本字段的条件。文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6675091/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com