I have a keyboard with a custom accessory view. I can get its height by registering for keyboardWillShowNotification
notification:
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShowNotification(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
And the callback handler:
@objc fileprivate func keyboardWillShowNotification(notification: NSNotification) {
guard let keybrdEndFrame = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue else {
return
}
print(">>>> height: \(keybrdEndFrame.size.height)")
}
However, in this the keybrdEndFrame.size.height
gives me the height of the keyboard + the height of the accessory view. While in my particular case I know the height of the accessory view (since I have implemented it), so I can calculate the height of keyboard, I would like to know if there is a more generic solution in which I could decouple the calculation from the custom accessory view.
So my question is - is there a way to retrieve the height of the keyboard without the accessory view? Or alternatively, is there a way to retrieve just the height of the accessory view currently presented with the keyboard?