Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertView with a textfield not popping up keyboard in iOS 8 [duplicate]

I have a UIAlertView with a textfield inside (UIAlertViewStylePlainTextInput) that automatically pops up a keyboard in iOS 7. However, when I upgraded to iOS 8, the keyboard didn't automatically popup and instead I would have to tap on the textfield to get the keyboard to popup. Is there anyway to restore that automatic keyboard popup to the UIAlertView textfield when I call it?

 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"" message:@"The amount?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    UITextField * alertTextField = [alert textFieldAtIndex:0];
    alertTextField.keyboardType = UIKeyboardTypeNumberPad;
    [alertTextField setTextAlignment:NSTextAlignmentCenter];
    [alert show];
    [alert release];

Update: [alertTextField becomeFirstResponder]; does not work nor does

 [[alert textFieldAtIndex:0] setDelegate:self];
 [[alert textFieldAtIndex:0] becomeFirstResponder];

Also, there is a textfield flashing indicator inside the textview, which is problematic because there is no actual keyboard that pops up automatically until the user taps on the textfield itself.

like image 990
Hamlier Walp Avatar asked Sep 05 '14 19:09

Hamlier Walp


1 Answers

I had to unselect "Connect Hardware Keyboard" in the iOS Simulator Hardware->Keyboard menu options for running in iOS 8.

like image 110
willhblackburn Avatar answered Oct 14 '22 21:10

willhblackburn