我用了 :
NotificationCenter.default.addObserver(self, selector:#selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil)
@objc func keyboardWillShow(notification: NSNotification) {
if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
let keyboardHeight : Int = Int(keyboardSize.height)
print("keyboardHeight",keyboardHeight)
KeyboardHeightVar = keyboardHeight
}
}
Run Code Online (Sandbox Code Playgroud)
进行更改以获取键盘的高度,但高度不包括建议栏。如何获得键盘高度加上建议栏高度的值?