gpt4 book ai didi

ios - 我无法在 swift ios 中从 appdelegate 访问 tabbarcontroller

转载 作者:行者123 更新时间:2023-11-29 00:33:40 26 4
gpt4 key购买 nike

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

self.window?.backgroundColor = UIColor.white
self.window?.makeKeyAndVisible()

let tabBarController = UITabBarController()
let myVC1 = ViewController(nibName: "ViewController", bundle: nil)
let myVC2 = ViewController1(nibName: "ViewController1", bundle: nil)
let controllers = [myVC1,myVC2]
tabBarController.viewControllers = controllers
window?.rootViewController = tabBarController
let firstImage = UIImage(named: "Search")
let secondImage = UIImage(named: "Search1")
myVC1.tabBarItem = UITabBarItem(
title: "Pie",
image: firstImage,
tag: 1)
myVC2.tabBarItem = UITabBarItem(
title: "Pizza",
image: secondImage,
tag:2)
// Override point for customization after application launch.
return true

每当我运行该应用程序时都会出现黑屏。

最佳答案

我认为你没有避免 UIWindow 大小window = UIWindow(框架:UIScreen.main.bounds)window?.rootViewController = UITabBarController()

或者你在设置 Root View Controller 时遇到了一些问题。

关于ios - 我无法在 swift ios 中从 appdelegate 访问 tabbarcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41135890/

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