Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIAlertView中的多个UITextField_Ios_Objective C_Ios7_Uitextfield_Uialertview - Fatal编程技术网

Ios UIAlertView中的多个UITextField

Ios UIAlertView中的多个UITextField,ios,objective-c,ios7,uitextfield,uialertview,Ios,Objective C,Ios7,Uitextfield,Uialertview,我使用UIAlertView显示带有用户名、电子邮件和密码的注册表。但我对UITextField有一个小问题: 错误: NSInvalidArgumentException',原因:'textFieldIndex(2)超出了文本字段数组的界限 我的代码 // iOS7 UIAlertView *registerAlertView = [[UIAlertView alloc] initWithTitle:

我使用UIAlertView显示带有用户名、电子邮件和密码的注册表。但我对UITextField有一个小问题:

错误:
NSInvalidArgumentException',原因:'textFieldIndex(2)超出了文本字段数组的界限

我的代码

// iOS7
        UIAlertView *registerAlertView = [[UIAlertView alloc]
                                       initWithTitle:@"Register"
                                       message:@"Enter your username, email & password."
                                       delegate:self
                                       cancelButtonTitle:@"Cancel"
                                       otherButtonTitles:@"Register", nil];
        [registerAlertView setAlertViewStyle:UIAlertViewStylePlainTextInput];

        UITextField *username = [registerAlertView textFieldAtIndex:0];
        UITextField *email = [registerAlertView textFieldAtIndex:1];
        UITextField *password = [registerAlertView textFieldAtIndex:2];
        password.secureTextEntry = YES;

        [registerAlertView show];

感谢您的回答。

警报样式
UIAlertViewStylePlainTextInput
仅提供一个文本字段。最多可以使用
UIAlertViewStyleLogin和PasswordInput
样式获得两个文本字段

您的代码尝试使用3个文本字段。这是不受支持的


如果希望有三个文本字段,则需要创建或查找自定义警报视图(如控件)。

警报样式
UIAlertViewStylePlainTextInput
仅提供一个文本字段。最多可以使用
UIAlertViewStyleLogin和PasswordInput
样式获得两个文本字段

您的代码尝试使用3个文本字段。这是不受支持的


如果希望有三个文本字段,则需要创建或查找自定义警报视图(如控件)。

尽管rmaddy是正确的,但最好指出UIAlertController确实支持UIAlertView不支持的多输入字段。;)漠视我知道你的代码是ios7的。IOS8中的UIAlertController不推荐使用UIAlertView虽然rmaddy是正确的,但最好指出UIAlertController确实支持UIAlertView不支持的多输入字段。;)漠视我知道你的代码是ios7的。iOS8中的UIAlertController不推荐使用UIAlertView