0

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.

burnsi
  • 6,194
  • 13
  • 17
  • 27
ohu
  • 111
  • 1
  • 2
  • 8
  • This thread might help: https://stackoverflow.com/questions/9088465/unbalanced-calls-to-begin-end-appearance-transitions-for-detailviewcontroller – soumil Aug 08 '22 at 14:43

1 Answers1

2

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()
DonMag
  • 69,424
  • 5
  • 50
  • 86