- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// 1. 创建微信控制器
WeChatTableViewController *weChatTVC = [[WeChatTableViewController new] autorelease];
weChatTVC.title = @"WeChat";
UINavigationController *weChatNC = [[[UINavigationController alloc] initWithRootViewController:weChatTVC] autorelease];
weChatNC.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"WeChat" image:[UIImage imageNamed:@"tabbar_mainframe"] tag:100] autorelease];
// 2. Contacts
ContactsTableViewController *contactsTVC = [[ContactsTableViewController new] autorelease];
contactsTVC.title = @"Contacts";
UINavigationController *contactsNC = [[[UINavigationController alloc] initWithRootViewController:contactsTVC] autorelease];
contactsNC.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"Contacts" image:[UIImage imageNamed:@"tabbar_contacts"] tag:101] autorelease];
// 3. Discover
DiscoverTableViewController *discoverTVC = [[DiscoverTableViewController new] autorelease];
discoverTVC.title = @"Discover";
UINavigationController *discoverNC = [[[UINavigationController alloc] initWithRootViewController:discoverTVC] autorelease];
discoverNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Discover" image:[UIImage imageNamed:@"tabbar_discover"] tag:102];
// 4. Me
MeTableViewController *meTVC = [[MeTableViewController new] autorelease];
meTVC.title = @"Me";
UINavigationController *meNC = [[[UINavigationController alloc] initWithRootViewController:meTVC] autorelease];
meNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Me" image:[UIImage imageNamed:@"tabbar_me"] tag:103];
// 5. 添加
self.viewControllers = @[weChatNC, contactsNC, discoverNC, meNC];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
#pragma mark - 设置window
self.window = [[[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds] autorelease];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
#pragma mark - 设置根视图控制器
RootViewController *rootTBC = [[RootViewController new] autorelease];
self.window.rootViewController = rootTBC;
// 设置所有的UINavigationBar的选染色
[UINavigationBar appearance].barTintColor = [UIColor colorWithWhite:0.347 alpha:1.000];
return YES;
}
- UITabBarController
UITabBarItem
继承UITabBarController,在里面添加了子控制器
AppIcon
- LaunchImage
应用程序名称
Block传值(从后往前传)
7.1 block属性,需要使用Copy(从栈区拷贝到堆区一份,自己管理block变量的内存)
7.2 在block内部,不使用self,防止‘循环引用’的发生。解决方案:__block总结