开发者

UINavigationController and UITableView

I would like to create a view where there is a navigation bar on top and uitableview as the content and a uitabbar at the bottom. I would like to create all of this programatically, without having to use the xib.. how do I do this??

So far I have:

@interface GroupViewController : UINavigationController <UITableViewDelegate, UITableViewDataSource>{
    UITableView * table;
    UITabBar * bar;

}

@property (nonatomic, retain) UITableView * table;
@property (nonatomic, retain) UITabBar * bar;

@end

The UITabBarItem when clicked will present a popup window (non switching the view, because if that's the case then I would need a UITabBa开发者_运维问答rViewController).

One of my concerns as well is where do I specify the location of the UITabBar in this overall view? In the UIViewDidLoad?


You need to start with view based application. And then create a UITabbarController in you appDelegate file.

Appdelegate.h

UITabBarController *tabBarController;
// set properties


Appdelegate.m

// Synthsize

tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;

//Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController  
Search * search = [[Search alloc] init];  
UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search];  

Nearby* nearby = [[Nearby alloc] init];  
UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby];  

Map* map = [[Map alloc] init];  
UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map];  

AboutUs* aboutUs = [[AboutUs alloc] init];  
UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs];  

Favorites* favorites = [[Favorites alloc] init];  
UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites];  

NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil];  

tabBarController.viewControllers = controllers;

[window addSubview:tabBarController.view];    

You can accordingly manage in which tab you want to place navigation controller or only a view controller.

Then in each of the view controllers mentioned above you need to implement

- (id)init {}  

in which you can set Tab name and image.


Create all the things(navigation bar, uitableview, tabbar) in loadview method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜