2016-12-14 8 views
0
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 

私はアプリを実行するたびに黒い画面が表示されます。私はappdelegateからtabbarcontrollerにアクセスできません

+0

あなたはストーリーボードを使用していますか? –

+0

@jigneshVadadoriya。いいえ私はxibを使用しています –

+0

次にXibからUITabBarControllerを取得 –

答えて

0

アプリケーションの先頭にwindow = UIWindowを追加する必要がありますDelegate didFinishLaunchingWithOptions:またはフレームサイズが設定されていません。それはなぜあなたが黒い画面を取得する理由。

window = UIWindow(frame: UIScreen.main.bounds) 

self.window?.backgroundColor = UIColor.white 


let tabBarController = UITabBarController() 
let myVC1 = UIViewController() 
let myVC2 = UIViewController() 
let controllers = [myVC1,myVC2] 
1

は、私はあなたがいないpervoid UIWindowサイズ ウィンドウ= UIWindowやったと思いますか?(フレーム:UIScreen.main.bounds) ウィンドウを.rootViewController = UITabBarController()

たり、いくつかの問題でルートビューコントローラの設定

関連する問題