In iOS 18, UINavigationController continuously executes pushViewController, and the lifecycle method is not executed when the viewController enters the stack

  let home = homeViewController()
    let rootNav = UINavigationController(rootViewController: home)
    
    
    window?.rootViewController = rootNav
    window?.makeKeyAndVisible()
    
    
    
    let second = SecondViewController()
    home.navigationController?.pushViewController(second, animated: false)

    
    let third = ThirdViewController()
    home.navigationController?.pushViewController(third, animated: false)

After the above is executed, the viewdidload and other related lifecycle methods in the SecondViewController are not executed。

Except for iOS18, other versions don't have this problem, so it's not a bug in iOS18, or iOS18 has optimized UINavigationController

The ThirdViewController call pop to return to the SecondViewController page is a lifecycle execution method, which is strange if it is an IOS18 bug

This is likely an expected behavior change in iOS 18. As UIKit doesn't get a change to display second before you push third there is no guarantee that we will treat it as having gotten on screen and therefore call any of its lifecycle methods.

In iOS 18, UINavigationController continuously executes pushViewController, and the lifecycle method is not executed when the viewController enters the stack
 
 
Q