UITabbarController
简介
iOS中的标签控制器,可以对多个控制器进行切换
标签控制器的特性
//委托
@property(nonatomic, assign) id< UITabBarControllerDelegate > delegate
//与这个控制器相关的标签栏
@property(nonatomic, readonly) UITabBar *tabBar
管理控制器
//标签栏里的控制器,数组
@property(nonatomic, copy) NSArray *viewControllers
//给标签控制器设置显示的控制器数组
- (void)setViewControllers:(NSArray *)viewControllers
animated:(BOOL)animated
//决定哪些viewController允许重排列
@property(nonatomic, copy) NSArray *customizableViewControllers
//UITabBar上最多可以显示5个Tab,当我们往UITabBarController中添加超过的viewController超过5个时候,最后一个一个就会自动变成more
@property(nonatomic, readonly) UINavigationController *moreNavigationController
管理选中的标签
//当前选中的控制器
@property(nonatomic, assign) UIViewController *selectedViewController
//选中的控制器的顺序的索引
@property(nonatomic) NSUInteger selectedIndex
UITabBarControllerDelegate
注意
管理标签栏的分区
- (BOOL)tabBarController:(UITabBarController *)tabBarController
shouldSelectViewController:(UIViewController *)viewController
- (void)tabBarController:(UITabBarController *)tabBarController
didSelectViewController:(UIViewController *)viewController
管理自定义标签栏
- (void)tabBarController:(UITabBarController *)tabBarController
willBeginCustomizingViewControllers:(NSArray *)viewControllers
- (void)tabBarController:(UITabBarController *)tabBarController
willEndCustomizingViewControllers:(NSArray *)viewControllers
changed:(BOOL)changed
- (void)tabBarController:(UITabBarController *)tabBarController
didEndCustomizingViewControllers:(NSArray *)viewControllers
changed:(BOOL)changed
重写视图旋转设置
- (NSUInteger)tabBarControllerSupportedInterfaceOrientations:(UITabBarController *)tabBarController
- (UIInterfaceOrientation)tabBarControllerPreferredInterfaceOrientationForPresentation:(UITabBarController *)tabBarController
自定义标签栏的过渡动画
- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController
animationControllerForTransitionFromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
- (id<UIViewControllerInteractiveTransitioning>)tabBarController:(UITabBarController *)tabBarController
interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController