Search code examples
swifttvos

Silver background showing between LaunchImage and TabBarViewController


My tvOS app does not have or need a proper login screen but I do have a check that is called from AppDelegate at first launch. The issue I am having is while the checkUser is happening with my backend the entire app turns to a silver color. Is there anything I can do about this? I have checked all viewcontroller backgrounds and I dont believe they are causing this. If I cannot fix this I'm wondering I wouldn't mind it being black instead but have no idea what causes this.

Flow: LaunchImage > (silver bg I want to remove during AppDelagate) > TabBarViewController/FirstViewController

In my AppDelegate...

func application(_ application: UIApplication, 
 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

     checkUser(); 
}

func checkUser() {
    //If user is valid...
    self.window = UIWindow(frame: UIScreen.main.bounds)
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let initialViewController = storyboard.instantiateViewController(withIdentifier: "TabBarViewController")
    self.window?.rootViewController = initialViewController
    self.window?.makeKeyAndVisible()
}

Solution

  • Set your rootViewController to something that you want to appear at the start (often apps will match their launch screen) before you call checkUser(). Then you can set the rootViewController to your TabBarViewController in the checkUser() when ready.

    There's no reason you can't change the rootViewController many times during your app's life time.