自定义键盘在iOS和斯威夫特身高4

问题描述 投票:1回答:2

如何获得通过的iOS给一个自定义键盘的视线的高度?

我目前手动设置键盘接口为iPhone 8加:

var keyboardHeight: CGFloat {
    return UIScreen.main.bounds.height > UIScreen.main.bounds.width ? 226 : 162
}

如何获得键盘的所有大小类编程的高度?

ios swift xcode keyboard
2个回答
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)

}

0
投票

该方法是通常的一个:listen to keyboard notifications and respond to them。 随着通知的发送endFrame字典的userInfo键包含键盘的正确尺寸。我考虑也最终accessoryInputView

© www.soinside.com 2019 - 2024. All rights reserved.