iOS 26: UIAlertController appears at the top of the screen

When displaying a full-screen model from a view that has constraints with KeyboardLayoutGuide, and then displaying a UIAlertController after closing that modal, the UIAlertController appears at the top of the screen.

This behavior appears only on iOS 26 devices with external keyboard devices (or simulators with "Connect Hardware Keyboard" setting on.)

  • iPhone 16 (simulator), iOS 26.0
  • iPhone 16 (simulator), iOS 18.5

Here's the sample code reproducing this issue:

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

        self.view.keyboardLayoutGuide.topAnchor.constraint(equalToSystemSpacingBelow: self.view.bottomAnchor, multiplier: 0).isActive = true

        let vc = UIViewController()
        vc.modalPresentationStyle = .fullScreen
        vc.view.backgroundColor = .white

        self.present(vc, animated: true) { [weak self] in
            vc.dismiss(animated: true) { [weak self] in
                let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
                alert.addAction(UIAlertAction(title: "OK", style: .default))
                alert.addAction(UIAlertAction(title: "CANCEL", style: .cancel))
                self?.present(alert, animated: true)
            }
        }
    }


}

Environment:

  • Xcode 26.0.1 (17A400)

I'm sorry, it seems the markdown preview is broken. The 1st image is the screen shot of iPhone 16 (simulator) with iOS 26.0 and 2nd is of iPhone 16 (simulator) with iOS 18.5.

Fixed.

iOS 26: UIAlertController appears at the top of the screen
 
 
Q