#import "RootViewController.h"
#import "FirstViewController.h"
#include "SecondViewController.h"
#import "ThirdViewController.h"
#import "FourthViewController.h"
#import "FifthViewController.h"
#import "SixthViewController.h"
@interface RootViewController : UITabBarController
@end
@interface RootViewController () <UITabBarControllerDelegate>
@end
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tabBar.tintColor = [UIColor orangeColor];
FirstViewController *firstVC = [[FirstViewController alloc] init];
firstVC.tabBarItem.title = @"第一页";
firstVC.tabBarItem.image = [UIImage imageNamed:@"home"];
firstVC.tabBarItem.badgeValue = @"99";
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.tabBarItem.title = @"联系人";
secondVC.tabBarItem.image = [UIImage imageNamed:@"contact"];
secondVC.tabBarItem.badgeValue = @"通知";
ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
thirdVC.tabBarItem.title = @"闹钟";
thirdVC.tabBarItem.image = [UIImage imageNamed:@"naozhong"];
FourthViewController *fourthVC = [[FourthViewController alloc] init];
fourthVC.tabBarItem.title = @"陌陌";
fourthVC.tabBarItem.image = [UIImage imageNamed:@"momo"];
fourthVC.tabBarItem.badgeValue = @"22";
FifthViewController *fifthVC = [[FifthViewController alloc] init];
fifthVC.tabBarItem.title = @"麦克";
fifthVC.tabBarItem.image = [UIImage imageNamed: @"maike"];
SixthViewController *sixthVC = [[SixthViewController alloc] init
];
sixthVC.tabBarItem.title = @"淘宝";
sixthVC.tabBarItem.image = [UIImage imageNamed:@"taobao"];
self.viewControllers = @[firstVC, secondVC, thirdVC, fourthVC, fifthVC, sixthVC];
[firstVC release];
[secondVC release];
[thirdVC release];
[fourthVC release];
[fifthVC release];
[sixthVC release];
self. delegate = self;
self.moreNavigationController.tabBarItem.badgeValue = @"33";
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - UITabBarControllerDelegate
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
if (viewController == tabBarController.viewControllers[2]) {
return YES;
}
return YES;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSLog(@"%@",viewController);
viewController.tabBarItem.badgeValue = nil;
}
- (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers {
NSLog(@"将要开始修改 viewControllers");
}
- (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers changed:(BOOL)changed {
NSLog(@"将要结束修改");
}
- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers changed:(BOOL)changed {
NSLog(@"已经结束修改");
}
- (UIInterfaceOrientationMask)tabBarControllerSupportedInterfaceOrientations:(UITabBarController *)tabBarController {
return UIInterfaceOrientationMaskLandscape;
}