iPhone AlertView文本字段键盘不可见

Hac*_*ord 3 iphone keyboard objective-c

我有一个警报视图,其中添加了uitextfield作为子视图.

在我的uitableview控制器中,键盘显示正常.

http://i301.photobucket.com/albums/nn76/hackmodford/c804bd91.jpg

然而,在另一种观点中,我想做同样的事情.因此,我没有使用UITableView控制器,而是使其成为UIViewController,以便我可以在视图的底部添加工具栏.

但是当我显示UIAlertView时,键盘被隐藏了.我认为它在视图后面,因为警报视图向上移动以便为键盘腾出空间.

http://i301.photobucket.com/albums/nn76/hackmodford/5680aaa2.jpg

有任何想法吗?

更新:

键盘被隐藏的原因是因为我在显示警报后解雇了一个modalviewcontroller.出于某种原因,我猜也会解雇键盘.刚刚重新安排顺序,适合现在正常工作......

cho*_*own 5

尝试实现该didPresentAlertView:方法并在里面设置文本字段,firstResponder如下所示:

- (IBAction)someActionThatTriggersAnAlertView:(id)sender {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TITLE" message:@"MESSAGE" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Done", nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    UITextField *someTextField = [alert textFieldAtIndex:0];
    someTextField.keyboardType = UIKeyboardTypeAlphabet;
    someTextField.keyboardAppearance = UIKeyboardAppearanceAlert;
    someTextField.autocorrectionType = UITextAutocorrectionTypeNo;
    [alert show];
    [alert release];
}

#pragma mark - UIAlertViewDelegate Methods

- (void)didPresentAlertView:(UIAlertView *)alertView {
    [[alertView textFieldAtIndex:0] becomeFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)

UIAlertView文档
UIAlertViewDelegate文档