Re: [問題] 如何指定某選項才載入UITabBarController?
其實作法與 AppDelegate 一樣,作法如下
UITabBarController *tabBar = [[[UITabBarController alloc] init] autorelease];
FirstViewController *controller1 =
[[[FirstViewController alloc] initWithNibName:@"FirstViewController"
bundle:nil] autorelease];
SecondViewController *controller2 =
[[[SecondViewController alloc] initWithNibName:@"SecondViewController"
bundle:nil] autorelease];
NSArray *controllers =
[NSArray arrayWithObjects:controller1, controller2, nil];
[tabBar setViewControllers:controllers];
[self presentModalViewController:tabBar animated:YES];
這時候你就會看到兩個 TabBar 的按鈕,但是都沒名稱
名稱是要在各自的 viewController 裡的
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
建立,只要使用 [self setTitle:@"Title Name"]; 即可
圖案就用 [[self tabBarItem] setImage:image];
這樣子就可以在任一介面下建立 TabBar 了
※ 引述《imasa (便當俠)》之銘言:
: 大家好,我第一次問 xcode 的問題
: 標題可能寫得不是很明確,請大家見諒
: 我的問題可以用下圖表示
: http://ppt.cc/ywJz
: 我在app啟動的時候載入了一個UITableView
: 並且在 didSelectRowAtIndexPath 中試圖啟動 UITabBarController
: UITabBarController *mainTabBar = [[UITabBarController alloc]
: initWithNibName:@"MainTabBar" bundle:nil];
: [self presentModalViewController:mainTabBar animated:YES];
: MainTabBar.xib 已經放了 UITabBarController 相關的物件
: 我在點選 AAA 後,app的確秀出了 UITabBarController (如圖右)
: 但這個 UITabBarController 卻是一片漆黑
: 除了下方可看出是 Tabbar 外其他什麼也沒有
: 想上網查詢 UITabBarController 相關的實作 example code
: 但是看到的都是app一啟動就載入 UITabBarController 的程式碼
: 這些範例程式碼幾乎都要從Appdelegate開始改起,但這並不是我要做的
: 請問我要修改什麼地方才能讓 UITabBarController 秀出應有的 View 呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.35.227.94
※ 編輯: darktt 來自: 114.35.227.94 (09/18 20:44)
推
09/19 12:04, , 1F
09/19 12:04, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):