Have a legacy UISplitViewController
iPad app that displays a modal view from the "right side" VC pane using presentViewController:animated:completion: with the modalPresentationStyle
set to UIModalPresentationFormSheet
. In viewDidAppear
of the modal view's VC, we call becomeFirstResponder on a UITextField
. In iOS6, this results in a centered modal view sliding up from the bottom which then focuses the KB. However, since iOS7, what occurs is after the view slides up from the bottom, it slides to the right by about (estimating) 200 points. Weird thing is, if you dismiss the keyboard, as soon as you do, the view slides back to it's centered position like it is on iOS6. From then on, while the modal view is up, KB focus causes it to stay centered and only slide up a little, which is normal iOS behavior for non full screen modal views. It's like once you dismiss the KB once it "corrects" itself from then on. I have experimented and found that:
- If you set
animated
to NO for thepresentViewController
call it works like iOS6. - If you don't call
becomeFirstResponder
at all, it works like iOS6. - If you call
performSelector:xxxxafterDelay:0
, passingbecomeFirstResponder
as the selector instead of callingbecomeFirstResponder
directly, it also works like iOS6.
Option 3 from above is currently my go forward workaround, but my question is: is this an iOS7 bug, or are we doing the wrong thing that was obviously ok in 6 but not in iOS7?
Only occurs post-iOS7. Only recreated once on simulator, but 100% of time on test device (iPad mini). From the searches I've done my current best guess (assuming our code isn't to blame post-iOS7) is there's a race condition type bug between the animations of the keyboard and the view sliding up from the bottom in the iOS UI layer that causes the view to shift right instead of up, like it normally does when a non full screen view is presented modally and the KB is popped. I got that theory after reading this similar SO question.