Swift iOS-如何从AppDelegate中删除UINavigationController?

Swift iOS-如何从AppDelegate中删除UINavigationController?,swift,uinavigationcontroller,uitabbarcontroller,Swift,Uinavigationcontroller,Uitabbarcontroller,我必须从我的应用程序中删除UINavigationController,才能添加uitabarcontroller,并保留 我的if语句按原样工作 我的代码: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let storyboard = UISt

我必须从我的应用程序中删除
UINavigationController
,才能添加
uitabarcontroller
,并保留 我的
if语句
按原样工作

我的代码:

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

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    if UserDefaults.standard.value(forKey: "URL") == nil
    {
        let viewController = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
        let navController = UINavigationController(rootViewController: viewController)
        self.window?.rootViewController = navController
        self.window?.makeKeyAndVisible()

    }else{

        let viewController = storyboard.instantiateViewController(withIdentifier: "ChannelsViewController") as! ChannelsViewController
        let navController = UINavigationController(rootViewController: viewController)
        self.window?.rootViewController = navController
        self.window?.makeKeyAndVisible()
    }

    return true
}

self.window?.rootViewController=viewController
?通过一些解释改进了仅代码的答案。
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {


let storyboard = UIStoryboard(name: "Main", bundle: nil)

    if UserDefaults .standard .value(forKey: "URL") == nil
    {
        let viewController = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
        self.window?.rootViewController = viewController
        self.window?.makeKeyAndVisible()

    }else{

        let viewController = storyboard.instantiateViewController(withIdentifier: "ChannelsViewController") as! ChannelsViewController
        self.window?.rootViewController = viewController
        self.window?.makeKeyAndVisible()
    }


    return true
}