Cocoa touch UIAlertView中的iPhone键盘弹出问题

Cocoa touch UIAlertView中的iPhone键盘弹出问题,cocoa-touch,Cocoa Touch,我想使用警报视图接受密码。下面是我正在使用的代码。但我不明白为什么键盘会弹出两次而不是一次?有什么想法吗 UIAlertView *passwordAlert = [[UIAlertView alloc] initWithTitle:@"Enter Password" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Sub

我想使用警报视图接受密码。下面是我正在使用的代码。但我不明白为什么键盘会弹出两次而不是一次?有什么想法吗

UIAlertView *passwordAlert = [[UIAlertView alloc]
         initWithTitle:@"Enter Password" message:@"" 
         delegate:self cancelButtonTitle:@"Cancel"          
         otherButtonTitles:@"Submit",nil];

[passwordAlert addTextFieldWithValue:@"" label:@"Password"];

UITextField *textfield = [passwordAlert textFieldAtIndex:0];
textfield.secureTextEntry = YES;
[passwordAlert setTag:10];
[passwordAlert show];

不完全确定addTextFieldWithValue是在哪里定义的,但您可能需要检查.xib文件,以确保没有像本文中那样在“阶段”上放置双重视图:

还有,看看这篇文章。看起来您可能必须“在显示警报视图之前,告诉文本字段成为第一响应者,您将得到两个键盘”:


没问题。我发现你使用的方法没有文档记录。真漂亮!这些方法有来源吗?在iPhone SDK中使用私有API是拒绝应用商店的理由。请记住这一点。此答案或链接中没有任何内容是私人的。