2011-06-16 26 views
0

我知道我能做到這一點如何使用TabBarViewController與NavigationController

[self.navigationController pushViewController:self.someUITabBarController animated:YES]; 

這意味着把UITabBarControllernavigationgController莫名其妙

什麼,如果我想someUITabBarController成爲第一個控制器(一位於最低層)navigationController

我根本無法改變NavigationControllerrootViewControllersomeUITabBarController

回答

2

呃不知道這是你想要的。下面這段代碼將放在你的「appDelegate」類的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions下。

UITabBarController *tabController = [[UITabBarController alloc] init]; 
UIViewController *viewController1 = ... 
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController1]; 

NSArray *controllers = [NSArray arrayWithObjects:navigationController, nil]; // can add more if you want 

[tabController setViewControllers:controllers]; 

// this is for custom title and image in the tabBar item 
navigationController.tabBarItem.title = @"abc"; 
[navigationController.tabBarItem setImage:[UIImage imageNamed:@"abc.png"]]; 

self.window.rootViewController = tabController; // or [self.window addSubview: tabController.view]; 
[self.window makeKeyAndVisible]; 
1

我不知道,如果這個工程。但試試這個,

UINavigationController *navCont = [[UINavigationController alloc] init]; 
[navCont pushViewController:navCont animated:NO]; 
相關問題