I had this same issue. I assume you don’t have a height set on the green block because you want it to fill up the remaining space of the keyboard. If you want the keyboard to be a CONSTANT height you can simply set a height constraint on the green block and you’re done, but because of screen sizes and orientations you probably don’t want one height for everything.
In iOS 9 the default size for a custom keyboard was the same as the system keyboard. So if you run this in iOS 9, the green block fills up the remaining space based on those dimensions. In iOS 10 for some reason there is no default height, and because your green block has no height constraint it thinks the height is zero.
To fix it you need to set a height for your keyboard. This is the code I wrote to handle it (and so far so good). Place this in the keyboardviewcontroller class before the ViewDidLoad and you should be good to go:
//***************************
//create constraint variable before function
var constraint = NSLayoutConstraint()
//function to set height
func setKeyboardHeight () {
let screenSize = UIScreen.mainScreen().bounds.size
let screenH = screenSize.height;
self.view.removeConstraint(constraint)
//you can set the values below as needed for your keyboard
if screenH >= 768 {
//for iPad landscape or portrait
self.constraint = NSLayoutConstraint(item: self.view, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 0.0, constant: 300.0)
self.view.addConstraint(self.constraint)
} else if screenH >= 414 {
//for iPhone portrait AND iPhone Plus landscape or portrait
self.constraint = NSLayoutConstraint(item: self.view, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 0.0, constant: 220.0)
self.view.addConstraint(self.constraint)
} else {
//for iPhone landscape
self.constraint = NSLayoutConstraint(item: self.view, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 0.0, constant: 140.0)
self.view.addConstraint(self.constraint)
}
}
//sets height when keyboard loads
override func updateViewConstraints() {
super.updateViewConstraints()
// Add custom view sizing constraints here
setKeyboardHeight()
}
//sets or changes height when device rotates
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
setKeyboardHeight()
}
//***************************
1
solved Custom Keyboard Storyboard with Xcode 8 beta