一、创建窗口
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds;
// 设置窗口的根控制器
self.window.rootViewController = [[UITabBarController alloc] init ];
// 显示窗口
[self.window makeKeyAndVisible];
二、初始化子控制器
①、自定义TabBarController 继承 UITabBarController
②、新建子控制器 AAAViewController 继承 UITableViewController
③、初始化一个子控制器
- (void)setupOneChildVC:(UIViewController *)child title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
//设置标题
child.tabBarItem.title = title;
//设置图片
child.tabBarItem.image = [UIImage imageNamed:imageName];
//设置选中的 图片
child.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
// 添加子控制器
[self addChildViewController:child];
}
④、初始化自己的所有控制器
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// 初始化自己的所有子控制器
}
return self;
}