【发布时间】:2014-12-21 16:30:43
【问题描述】:
在AppDelegate/didFinishLaunchingWithOptions 上创建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。有什么想法吗?
【问题讨论】:
标签: ios swift uitabbarcontroller uinavigationbar