我總是喜歡通過編碼創建複雜的多視圖。 您需要從基於視圖的應用程序開始。然後在你的appDelegate文件中創建一個UITabbarController。
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];
您可以相應地管理在哪個選項卡中放置導航控制器或只有視圖控制器。
在上述各你所提到的視圖控制器的
然後需要實現
- (id)init {}
,可以在其中設置選項卡名稱和圖像。
謝謝你Nitish,我仍然不能看到讓它出現。請介紹一下這個項目併發郵件給我吧。 – user754975 2011-05-16 19:11:31
由於某些原因,我無法上傳壓縮文件。你能告訴我你在哪裏遇到問題,你得到的錯誤是什麼? – Nitish 2011-05-17 05:02:06
嘗試將其上傳到像upload.com這樣的轉儲網站,並將鏈接 – user754975 2011-05-19 18:20:52