Modal View Controller with keyboard on landscape i

2019-01-15 03:56发布

问题:

This question already has an answer here:

  • Modal Dialog Does Not Dismiss Keyboard 6 answers

I present a modal view controller on my on my iPad with UIModalPresentationFormSheet presentation style and UIModalTransitionStyleCoverVertical transition style. The Modal View Controller contains a UIWebView with some TextFields on it. When the user taps one of the text fields the keyboard comes up.

I have noticed that in landscape mode after the keyboard is shown, if I try to dismiss the modal view controller with animation the view changes its position from the center of the screen to the left side just before the animation starts..

This happens only if the keyboard is up and only in landscape mode on the iPad. If the user closes the modal view without pressing on any text field this doesn't happen.

Anyone familiar with this strange behavior?

回答1:

I just found a solution to this. Call resignFirstResponder on the current responder and then call dismissModalViewControllerAnimated".

Definitely a bug with iOS but this works for me.



回答2:

Yes! I'm thinking this is a bug, the Wordpress app exhibits this problem too, though strangely, Mail.app doesn't?