KeyboardLayoutGuide very unreliable on iOS17 RC

KeyboardLayoutGuide is unusable on iOS17 Release Candidate. Constantly reporting wrong values and missing updates.

Sample app description

NavigationController with two ViewControllers, the first one making use of KeyboardLayoutGuide to place a view on top of the keyboard, second ViewController with an InputField.

Here the logic using keyboardLayoutGuide.

class FirstViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let v = UILabel()
        v.textColor = .white
        v.textAlignment = .center
        v.text = "View always above Keyboard"
        v.backgroundColor = .blue
        v.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(v)
        
        NSLayoutConstraint.activate([
            v.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            v.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            v.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
        ])
    }
}

iPhone Scenario

  • Push the second ViewController
  • Focus the Input Field
  • Pop the ViewController

KeyboardLayoutGuide will report to the first ViewController as the keyboard is still visible, misplacing any view that makes use of it.

iPad Scenario 1

  • Enable Stage Manager
  • Run the Sample app and any other app side by side
  • Focus on any input field on the second app
  • KeyboardLayoutGuide will correctly update the view that makes use of it on the Sample App.
  • Tap on the Sample app to acquire focus

KeyboardLayoutGuide won't be updated, misplacing any views that makes use of it.

iPad Scenario 2

  • Run the Sample app and any other app side by side
  • Focus on any input field on the second app
  • Rotate the device

KeyboardLayoutGuide will misplace any view that makes use of it.

Feedback was submitted FB12844057

iPad Scenario 3

This one doesn't even need the Sample app, it's reproducible on any app that has views that follows the keyboard, breaking pretty much any messaging app, including Apple Messages.

  • Enable Stage Manager
  • Open Apple Messages and any other app side by side
  • Open a chat and dismiss the keyboard on Apple Messages
  • Focus on any input field on the second app
  • While the keyboard is visible, move Apple Messages around by using the top mid 3-dots handle

The message entry view will be misplaced.

Hi, I have the same problem too. @MarioBarbosa have you by any chance found a solution to this bug?

I'm experiencing the same issue even in iOS 17.3.1. Did anyone find a fix or a workaround for this issue? @MarioBarbosa @mricca

No, my solution is to use the old notification-based keyboard avoidance strategy. keyboardLayoutGuide has just always been broken in iOS 17. 🫠

KeyboardLayoutGuide very unreliable on iOS17 RC
 
 
Q