如何获取iOS给定制键盘的视图高度?
我目前正在为iPhone 8 Plus手动设置键盘界面:
var keyboardHeight: CGFloat {
return UIScreen.main.bounds.height > UIScreen.main.bounds.width ? 226 : 162
}
如何以编程方式获取所有大小类的键盘高度?
答案 0 :(得分:0)
方式通常是:listen to keyboard notifications and respond to them
与通知一起发送的endFrame
字典的userInfo
键包含正确的键盘大小。我还考虑了accessoryInputView
。
答案 1 :(得分:0)
尝试
override func viewDidLoad() {
super.viewDidLoad()
let desiredHeight: CGFloat = 500
let heightConstraint = NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: desiredHeight)
view.addConstraint(heightConstraint)
self.nextKeyboardButton.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
}