iOS 16 - Child controller not respecting safeAreaLayoutGuide

Number:rdar://FB9997891 Date Originated:
Status:Open Resolved:
Product:UIKit Framework Product Version:iOS 16
Classification:Very High Reproducible:Yes
Tested on iOS 15.5 iPhone 13 Pro and it works, it doesn't on iPhone 16. 

Any clue what's going on?

Here's some sample code: 

class ViewController: UIViewController {

    let childController = ChildViewController()

    override func viewDidLoad() {
        // Do any additional setup after loading the view.
        view.backgroundColor = .yellow
        childController.willMove(toParent: self)

        childController.view.translatesAutoresizingMaskIntoConstraints = false
                    childController.view.topAnchor.constraint(equalTo: view.topAnchor),
                    childController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
                    childController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
                    childController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor)
        childController.didMove(toParent: self)

class ChildViewController: UIViewController {

    override func viewDidLoad() {
        // Do any additional setup after loading the view.
        let avoidSafeArea = UIView()
        avoidSafeArea.backgroundColor = .green
        avoidSafeArea.translatesAutoresizingMaskIntoConstraints = false
            avoidSafeArea.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
            avoidSafeArea.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
            avoidSafeArea.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
            avoidSafeArea.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)


You may be calling the wrong function

"Der Teilweise" wants to let you know:

Basically, you are calling willMove(:) but should be calling addChild(:).

By tempelmann at April 16, 2023, 5:35 p.m. (reply...)


Clarifying that this testing happened on Xcode, using simulators.

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!