【发布时间】:2010-11-10 11:56:01
【问题描述】:
您好,我正在开发一个应用程序,它有一个登录表单和另一个称为邀请的视图。现在我的登录视图中出现了我的问题 -(无效)按钮按下 { 邀请 *obj = [[邀请分配]init]; [self.navigationController pushViewController:obj 动画:YES]; }
现在在邀请视图中,我想要显示一个标签栏,所以我编写了一个看起来像这样的代码
objTabbar = [[UITabBar alloc]init];
HomeItem = [[UITabBarItem alloc]initWithTitle:@"Home" image:[UIImage imageNamed:@"house.png"] tag:0];
BluetoothItem = [[UITabBarItem alloc]initWithTitle:@"Bluetooth" image:[UIImage imageNamed:@"bluetooth.png"] tag:1];
NSArray *a = [[NSArray alloc]initWithObjects:HomeItem,BluetoothItem,nil];
objTabbar.items = a;
在 LoadView 方法中我这样做了
- (void)loadView {
[super loadView];
self.navigationItem.hidesBackButton = YES;
[self.view addSubview:objTabbar];
}
现在代码构建成功,但问题是标签栏没有显示。我尝试了 tabbarController 并做到了这一点
tabbarController.view = objTabbar;
并在loadView方法中添加了tabbarController
[self.view addSubview:tabbarController.view];
但还是没有成功
请帮帮我,让我知道我哪里出错了 谢谢你
【问题讨论】:
-
你能在 IB 中创建你的 TabBar 吗?这就是 IB 的用途......
-
@Richard:我知道我这样做了,但我不想使用 IB,我正在尝试通过代码来做到这一点,所以先生你对编码有什么建议吗?有帮助
标签: iphone objective-c xcode uitabbar