0

I am working on an iOS custom keyboard extension. My keyboard appears shorter than regular keyboard. See this:

Keyboard height is short

Please follow these steps to produce the result:

  1. Create an xCode project and add a Keyboard Extension target
  2. Add a new Storyboard file and change plist to use the newly added Storyboard. (You can follow a tutorial on Youtube "How To Create a Custom Keyboard Using Storyboard Xcode" )
  3. Add a UIViewController and drag 2 UIButtons to the view controller.
  4. Set constraints as in this: set top, left, bottom, same width and height constraints
  5. The UIButtons should be stretched and have equal height.
  6. Run it. The keyboard height is shorter than normal and the 2 buttons don't look as they do in the storyboard.

Development Environment:

  • Macbook Pro, MacOS X El Capitan, 8GB RAM, 512GB SSD
  • xCode 8.0 (8A218a)
  • Tested on all iPhone simulators
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

3 Answers3

1

I had similar issue (xcode 8.3), my keyboard would be smaller then the standard one (default settings). For organising the keys I use stack views which help layout the buttons without hard constraints. What I do to preserve the height of the keyboard is setting the relation of height constraints for each stack view to "Greater Than or Equal" (Default value is Equal): new settings and preserved keyboard height

best, Yury

Yury
  • 11
  • 1
0

Did you use constraint for height for your keyboard's view? If no, try to set this.

Also, put a checkmark to 'height' value in your screenshot for a buttons (or just make a ctrl-drag from the button to herself and choose 'height' item in the pop-up - this will work for keyboard's view too).

ArtStyle
  • 333
  • 3
  • 16
  • Thanks for reply. I have solved this by adding height constraint to the view. But then the height is fixed in both orientations and also on all devices. Is there way to get default height of iOS keyboard? – Chandarong Nuon Sep 27 '16 at 09:09
  • @ChandarongNuon Glad it helped. To get default iOS keyboard height You could use `CGFloat height = [[notification.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].height; self.YourConstraint.constant = height; [self.view layoutIfNeeded];` that code. It will return you 224 in portrait (you can also just use this value in constraint in storyboard). – ArtStyle Sep 27 '16 at 13:20
0

I had a similar problem and solved it by setting a new constrain for the height enter image description here

emiliomarin
  • 362
  • 3
  • 22
  • Thanks for reply. I have solved this by adding height constraint to the view. But then the height is fixed in both orientations and also on all devices. Is there way to get default height of iOS keyboard? – Chandarong Nuon Sep 27 '16 at 09:09
  • @ChandarongNuon Check this out: http://stackoverflow.com/questions/11284321/what-is-the-height-of-iphones-onscreen-keyboard – emiliomarin Sep 27 '16 at 12:09