gpt4 book ai didi

ios - 在 IOS7 中验证更多文本字段

转载 作者:行者123 更新时间:2023-11-28 22:12:55 25 4
gpt4 key购买 nike

您好,我正在验证一个以上的文本字段,它不能正常工作,例如,如果有 4 个字段意味着它的验证适用于 3 个字段,它在第 4 个不工作,我尝试使用其他如果在 objective-c 中,就像我们通常在c 和其他语言,但如果 else 不可用,请告诉我如何解决此问题。

       - (IBAction)reg:(id)sender {
if ([name.text length] > 25 && [city.text length] > 25) {
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Message" message:@"pls enter less then 25 character in name and city" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert1 show];
[alert1 release];
}

if ([self validateEmail:[email text]] != 1) {
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Message" message:@"Pls enter valid email id" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert1 show];
[alert1 release];
}

if ([self phonevalidate:[phone text]] != 1) {
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Message" message:@"Pls enter only 10 numbers" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert1 show];
[alert1 release];
}

if ([name.text length] < 1 && [city.text length] < 1) {
UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"Message" message:@"pls fill the empty field" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert1 show];
[alert1 release];
}

else {
pollpoliticalViewController *pollVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"PollPoliticalVCID"];

//pollpoliticalViewController *vc2 = [[pollpoliticalViewController alloc] init];
[self presentViewController:pollVC animated:YES completion:nil];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Thanks For The Registration" delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alert show];
[alert release];
}
}

在上面的代码中,第一个验证不起作用,请告诉我是否有另一种方法可以验证一个以上的文本字段,或者请告诉我在上面的代码中哪里做错了。

谢谢。

最佳答案

...else if 不可用...

else if 在 Objective C 中可用。

if () {
} else if () {
} else if () {
} else {
}

http://en.wikipedia.org/wiki/Objective-C

Objective-C is a thin layer on top of C, and moreover is a strict superset of C; it is possible to compile any C program with an Objective-C compiler, and to freely include C code within an Objective-C class.[7]

Objective-C derives its object syntax from Smalltalk. All of the syntax for non-object-oriented operations (including primitive variables, pre-processing, expressions, function declarations, and function calls) are identical to that of C, while the syntax for object-oriented features is an implementation of Smalltalk-style messaging.

关于ios - 在 IOS7 中验证更多文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22456216/

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