2017-03-08 39 views
0

我很抱歉打擾你,我真的很喜歡Material Project,我希望我可以熟練地使用它並製作更漂亮的應用程序。我不知道我是否可以知道如何在同一時間使用NavigationController和PageTabBarController,因爲如果我想使用它們中的一個,我必須將它作爲rootViewController設置在AppDelegate中,那麼我應該如何處理另一個一? 謝謝。如何在同一時間使用NavigationController和PageTabBarController?

回答

0

我很高興你正在享受材質:)

看看這篇文章Application Architecture with Material

基本上,你可以設置PageTabBarControllerNavigationControllerrootViewController,就像這樣:

import UIKit 
import Material 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 
    var window: UIWindow? 

    func applicationDidFinishLaunching(_ application: UIApplication) { 
     let pageTabBarController = AppPageTabBarController(viewControllers: [RedViewController(), GreenViewController(), BlueViewController()], selectedIndex: 0) 

     window = UIWindow(frame: Screen.bounds) 
     window!.rootViewController = AppNavigationController(rootViewController: pageTabBarController) 
     window!.makeKeyAndVisible() 
    } 
} 

應該這樣做。祝一切順利。

+0

我已經試過了,但我怎麼能修改NavigationController?我現在甚至不能編輯它的標題 – aUcid

+0

您只需要通過更改navigationItem來添加標題,無論哪個視圖是rootViewController。所以在這種情況下,它將在PageTabBarController本身中被訪問。 – CosmicMind

0

在故事板,選擇視圖,然後編輯 - >嵌入在 - >導航控制器