If you are seeing the same thing please reply to this post.
The firing order was changed when tapping a textView or textField. I first noticed this in iOS 15.6.1 on my physical device. If I send the app to a physical device running iOS 15.5 everything worked fine. Once I updated the device to iOS 15.6.1 or higher the change in firing order broke the ability to get the keyboard height when the textView was first tapped. It's happening on both iPad and iPhone.
In Xcode 13.4.1, iOS 15.5 and before. keyboardWillShow fired then textViewDidBeginEditing fired after. This allowed to get the keyboard height before the textView became active and thus move the textView up the proper amount.
In Xcode 14.0.1, or anything above iOS 15.5. textViewDidBeginEditing fires then keyboardWillShow fires after.
So if you're moving the textview up to clear the keyboard it won't work right anymore because you won't get the keyboard height until after the textView has become firstResponder.
The firing order was also changed for textFields.
I thought about hard-coding in the keyboard heights for each device but that really doesn't make sense. That and what if Apple changes the keyboard height.
I have filed a bug report but so far no response. If you're using notificationCenter to get the keyboard height please check if your app is broken too. If so, please file a bug report so we can get some traction. I have several apps I'm waiting to release and this is holding me up.
You can use the code below to check the before and after firing order. Keep in mind that the textView delegate needs to be the view.
In viewDidLoad I have this.
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil)
The selector for NotificationCenter.default.addObserver
// MARK: - get the keyboard height
@objc func keyboardWillShow(notification: NSNotification)
{
if let keyboardRectValue = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue
{
print("keyboardHeight ran \(keyboardHeight)")
}
}
Then I have:
// MARK: - TextView Editing Begin.
func textViewDidBeginEditing(_ textView: UITextView)
{
print("textViewDidBeginEditing ran")
}