1

When I use UIAlertController with addTextField on iPad, the keyboard doesn't rotate properly from iOS10.

It was working fine with iOS9, does anybody know the way to fix it?

enter image description here

UIAlertController *alert =   [UIAlertController
                              alertControllerWithTitle:@"title"
                              message:nil
                              preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *done = [UIAlertAction actionWithTitle:NSLocalizedString(@"Done", nil)
                                               style:UIAlertActionStyleDefault
                                             handler:^(UIAlertAction * action) {

                                                 UITextField *textField = alert.textFields.firstObject;
                                             }];

UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
                                                 style:UIAlertActionStyleCancel
                                               handler:nil];

[alert addAction:cancel];
[alert addAction:done];

[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
}];

[self presentViewController:alert animated:YES completion:nil];
Umeumeume
  • 1,952
  • 3
  • 21
  • 40
  • I tried the same code and its working fine for me. – Annie Gupta Oct 29 '16 at 13:01
  • thanks, that means this could be another reason. I will look into something else. – Umeumeume Oct 29 '16 at 18:29
  • I found out that this issue has been fixed on Xcode 8.2 beta, so I will wait for the next Xcode update. – Umeumeume Nov 02 '16 at 07:44
  • Great!! Surprisingly I am using Xcode 8.0 and I did not get any such issue. Could you share the URL where you have read this!! – Annie Gupta Nov 02 '16 at 07:57
  • I just downloaded the Xcode 8.2 beta from apple website and tried it myself. This issue doesn't happen usually even with Xcode 8.1, but in my project, it happens for some reason. Maybe it is because of navi bar or storyboard or something related. – Umeumeume Nov 03 '16 at 05:45
  • I have this issue now (XCode 8.2.1). My screen is set to allow only Landscape Left and Landscape Right orientations. Did anyone find out why this is happening? – Armin Feb 03 '17 at 13:19
  • Look at this solution, It works for me. https://stackoverflow.com/a/53468939/1944886 – Oriel Dayanim Nov 25 '18 at 15:25

0 Answers0