简体   繁体   中英

iOS - Keyboard hides UIAlertView with UITextfield

I have a UIAlertView with a UITextField . I want the user to type in something and tap OK . But when the keyboard appears, it hides the buttons of the UIAlertView . Is there a way to make the UIAlertView move when the keyboard is shown. Or just move it upward so the buttons will be seen by the user?

This is the code I use:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Other", nil] ;
alertView.tag = 2;
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField * alertTextField = [alertView textFieldAtIndex:0];
alertTextField.keyboardType = UIKeyboardTypePhonePad;
CGRect frame = alertView.frame;
frame.origin.y = -140;
alertView.frame = frame;
alertTextField.text = @"some text";
[alertView show];

我不知道警报视图本身是否可以定位,但是也许您可以将其放入滚动视图中,并且当用户点击文本字段时,它只会为您滚动到可见区域。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM