Do remember that, with iOS 8, the onscreen keyboard's size can vary. Don't assume that the onscreen keyboard will always be visible (with a specific height) or invisible.
Now, with iOS 8, the user can also swipe the text-prediction area on and off... and when they do this, it would kick off an app's keyboardWillShow
event again.
This will break a lot of legacy code samples, which recommended writing a keyboardWillShow
event, which merely measures the current height of the onscreen keyboard, and shifting your controls up or down on the page by this (absolute) amount.
In other words, if you see any sample code, which just tells you to add a keyboardWillShow
event, measure the keyboard height, then resize your controls' heights by this amount, this will no longer always work.
In my example above, I used the sample code from the following site, which animates the vertical constraints constant
value.
In my app, I added a constraint to my UITextView
, set to the bottom of the screen. When the screen first appeared, I stored this initial vertical distance.
Then, whenever my keyboardWillShow
event gets kicked off, I add the (new) keyboard height to this original constraint value (so the constraint resizes the control's height).
Yeah. It's ugly.
And I'm a little annoyed/surprised that XCode 6's horribly-painful AutoLayout doesn't just allow us to attach the bottoms of controls to either the bottom of the screen, or the top of onscreen keyboard.
Perhaps I'm missing something.
Other than my sanity.