我想創建導航欄,但什麼也沒發生如何以編程方式添加導航控制器,我使用XIB文件迅速
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let viewController = DummyViewController(nibName: nil, bundle: nil)
let navigationController = UINavigationController(rootViewController: viewController)
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
let tabBarController = UITabBarController()
let tabViewController1 = DummyViewController(
nibName: "DummyViewController",
bundle: nil)
let tabViewController2 = SearchViewController(
nibName:"SearchViewController",
bundle: nil)
tabViewController1.tabBarItem = UITabBarItem(
title: "Location",
image: UIImage(named: "ic_location_blue"),
tag: 1)
tabViewController2.tabBarItem = UITabBarItem(
title: "Search",
image:UIImage(named: "ic_search_blue") ,
tag:2)
let controllers = [tabViewController1,tabViewController2]
tabBarController.viewControllers = controllers
window?.rootViewController = tabBarController
return true
}
似乎因爲我添加self.window?.rootViewController = navigationController
和window?.rootViewController = tabBarController
我使用的廈門國際銀行文件,並不知道如何使用標籤欄控制器與導航控制器在一起,謝謝。
然後通過程序或在廈門國際銀行解決了嗎? – Vive