Home > Software design >  (2022) Getting error: Unbalanced calls to begin/end appearance transitions for <UINavigationContr
(2022) Getting error: Unbalanced calls to begin/end appearance transitions for <UINavigationContr

Time:08-09

All previous answers to this question appear to be very outdated and in Objective-C. I created a new project and in scene delegate 'scene' func, added the following code for my root viewController:

  guard let scene = (scene as? UIWindowScene) else { return }
    let window = UIWindow(windowScene: scene)
    let nav = UINavigationController(rootViewController: LoginController())
    window.rootViewController = nav
    window.makeKeyAndVisible()

I then created that controller and made the background color red to test UI. It didn't work. Print statements running the the viewDidLoad run, but the UI does not run. I always do this and never get this error... any help is appreciated.

CodePudding user response:

You're missing a line...

    guard let scene = (scene as? UIWindowScene) else { return }
    let window = UIWindow(windowScene: scene)
    let nav = UINavigationController(rootViewController: LoginController())
    window.rootViewController = nav
    
    // missing this line
    self.window = window
    
    window.makeKeyAndVisible()
  • Related