在我创建了TabBarController
后,我如何在Swift中以编程方式添加导航接口。以下是我的当前代码:
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let tabBarController = UITabBarController()
let purchaseViewController = PurchaseViewController(nibName: "PurchaseViewController", bundle: nil)
let financeViewController = FinanceViewController(nibName: "FinanceViewController", bundle: nil)
tabBarController.viewControllers = [purchaseViewController, financeViewController]
self.window!.rootViewController = tabBarController
self.window!.makeKeyAndVisible()
我正在查看文档。它有以下准则。
- (void)applicationDidFinishLaunching:(UIApplication *)application {
self.tabBarController = [[UITabBarController alloc] init];
MyViewController1* vc1 = [[MyViewController1 alloc] init];
MyViewController2* vc2 = [[MyViewController2 alloc] init];
MyViewController3* vc3 = [[MyViewController3 alloc] init];
MyNavRootViewController* vc4 = [[MyNavRootViewController alloc] init];
UINavigationController* navController = [[UINavigationController alloc]
initWithRootViewController:vc4];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, navController, nil];
tabBarController.viewControllers = controllers;
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.rootViewController = tabBarController;
[window makeKeyAndVisible];
}
问题,我无法正确地在Swift上完成这个操作。 我想在AppDelegate
中设置和修改NavigationBar
的单独方法。 有什么想法吗?
var navigationController1 = UINavigationController(rootViewController: purchaseViewController); tabBarController.viewControllers = [navigationController1, navigationController2]
- evnaz