我需要以编程方式将 UItabbar 添加到 UIView。这是下面的代码,应用程序从 RootViewTableController 开始,然后被推送到此视图,但选项卡不起作用,也许是 MainWindow.xib 中的问题?:
// TabBarController.h
@interface TabBarController : UITabBarController
@end
// TabBarController.m
#import "TabBarController.h"
#import "FirstV.h"
@implementation TabBarController
-(void)viewDidLoad {
NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];
UIViewController *vc;
vc = [[UIViewController alloc] init];
vc.title = @"A";
[listOfViewControllers addObject:vc];
[vc release];
vc = [[UIViewController alloc] init];
vc.title = @"B";
[listOfViewControllers addObject:vc];
[vc release];
[self.tabBarController setViewControllers:listOfViewControllers animated:YES];
[super viewDidLoad];
}
@end
截图在这里:
如您所见,底部没有选项卡,我应该将 UItabbar 元素拖放到视图中吗?