作者darktt (小朱)
看板MacDev
标题Re: [问题] 如何指定某选项才载入UITabBarController?
时间Tue Sep 18 20:43:47 2012
其实作法与 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)
1F:推 imasa:照着你的方式做真的做出来了,非常感谢!:p 09/19 12:04