开发者

TabViewControllers with Navigation/Tableviews reading from sql

开发者 https://www.devze.com 2023-03-06 07:13 出处:网络
Good Morning Guys/Girls I am very new at programming for the iPhone, i have done alot of examples.I can create开发者_开发技巧 tabview project successfully and tableviews opening from SQL.

Good Morning Guys/Girls

I am very new at programming for the iPhone, i have done alot of examples. I can create开发者_开发技巧 tabview project successfully and tableviews opening from SQL.

However i am finding it very difficult to try and put them all together, i am not sure i am getting the delegates very well.

I would like to ask someone if possible to please please help me with this problem to try and understand this better.

What i am trying to do exactly is have a TabView Project, each tab would have a navigationcontroller page (so a table with say search on top, and table view) the data is being populated either from sqllite3 or datacore.

Thats it.

it seems simple enough, but i am sorry, i need to see a working example to see how these multiple controllers are being loaded. Do you delegate each in a different class? please if someone can make an example to so i can load it and see.

thank you Eden



I always prefer creating complex multiviews through coding. 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.

0

精彩评论

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