开发者

Navigation-based app with TabBar

I'm using Navigation-based Application Template with Core Data. Could anyone please tell me how to and a TabBar on the bottom of the view. I am using UITableView, so If I add UITabBar as subview, the TabBar is moving along with tableView when scrolling. I would like to switch between views with TabBar, first "segment" of TabBar should open the RootView (NavigationBar with TableView),and second some other view.

Now I did this:

UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewController = [NSArray arrayWithObject:yourNavigationController];
self.window.rootViewController = tabBarController
[tabBarController release];

that works fine, but how can I add more Items to UITabBar and for each Item some other view? TabBar has now just one Item on which rootView 开发者_如何学编程is loaded Thanks!


Use UITabBarController as your root view controller in your application delegate:

UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewController = [NSArray arrayWithObject:yourNavigationController];
self.window.rootViewController = tabBarController
[tabBarController release];


Its simple one, just add UITabbarController to your code and then made the first tab controller to be a navigation controller. And point that navigation controller to your controller which has table view that you want to show.


If you are doing it programmatically you can use this:

FirstViewController *first=[FirstViewController alloc]]init];
UINavigationController *nav=[UINavigationController alloc]]initwithRootViewcontroller:first];

UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewController = [NSArray arrayWithObject:first];

[tabBarController release];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜