gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 11:12:08 24 4
gpt4 key购买 nike

我必须删除UINavigationController从我的应用程序添加 UITabBarController并保留我的if statement按原样工作。

我的代码:

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
}

最佳答案

    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
}

关于swift - iOS - 如何从 AppDelegate 中删除 UINavigationController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52076252/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com