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
每当我运行应用程序时都会出现黑屏。
答案 0 :(得分:1)
我认为你不会破坏UIWindow的大小 window = UIWindow(frame:UIScreen.main.bounds) 窗口?.rootViewController = UITabBarController()
或者您在设置根视图控制器时遇到了一些问题。
答案 1 :(得分:0)
您需要在app Delegate didFinishLaunchingWithOptions的开头添加window = UIWindow:否则没有设置帧大小。这就是为什么你的黑屏。
__setitem__