Full source code for the project: https://github.com/yichizhang/CustomHeightKeyboard.git
I’ve been building an iOS keyboard app: AGK Ancient Greek Keyboard (Polytonic Greek)
In the app, I would like to have custom height for the keyboard, and the height of it changes depending on the orientation of the device (or depending the size of the screen, since from iOS 8,
[UIScreen bounds] is interface-oriented).
It should be possible because in Apple’s App Extension Programming Guide: Custom Keyboard, there is a note on keyboard height:
In iOS 8.0, you can adjust a custom keyboard’s height any time after its primary view initially draws on screen.
The solution (works for both iOS 8 and iOS 9)
It’s basically adding an extra height constraint to
view (NB: they are identical) in
It works perfectly in iOS 8, but not iOS 9. I figured out a workaround for iOS 9. It’s simple - just move ‘next keyboard button’ constraints set up code to
Full source code: https://github.com/yichizhang/CustomHeightKeyboard.git
I’m not entirely sure how it works. I’ve tried putting methods like
layoutIfNeeded in different places and it didn’t work.
If you know why, please do not hesitate to leave a comment.