How do I dismiss a rootViewController before presenting a new UITabBarController?

前端 未结 3 645
臣服心动
臣服心动 2021-01-29 06:53

I\'ve set up a UIViewController as my rootViewController in AppDelegate, however, when a user logs in or skips it I am presenting a UITabBarController over the top.

I n

3条回答
  •  半阙折子戏
    2021-01-29 07:47

    you do not need to present the UITabBarViewController and then dismiss the LoginViewController, you just need to reset the UITabBarViewController as a rootViewController for you app after login or skip as the following:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    
    // Override point for customization after application launch.
    
    let yourTabBar = UIStoryboard(name: "YOUR_STORYBOARD_NAME", bundle: nil).instantiateViewController(withIdentifier: "YOUR_UITABBARCONTROLLER_ID")
    self.window!.rootViewController = yourTabBar
    self.window!.makeKeyAndVisible()
    return true
    }
    

提交回复
热议问题