iOS开发中UITabBarController的使用示例

2020-01-14 16:38:32王冬梅

// 控制哪些ViewController的标签栏能被点击
- (BOOL)tabBarController:(UITabBarController *)tabBarControllershouldSelectViewController:(UIViewController *)viewController{
    // 代表HMT_CViewController这个View无法显示,无法点击到它代表的标签栏
    if ([viewControllerisKindOfClass:[HMT_CViewControllerclass]]) {
        returnNO;
    }
    returnYES;
}

// 选中哪个标签栏,一个监控作用吧
- (void)tabBarController:(UITabBarController *)tabBarControllerdidSelectViewController:(UIViewController *)viewController{

}

// More view controller将要开始编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerwillBeginCustomizingViewControllers:(NSArray *)viewControllers{

}
// More view controller将要结束编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerwillEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed{

}
// More view controller编辑
- (void)tabBarController:(UITabBarController *)tabBarControllerdidEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed{

}

#import "HMT-AViewController.h"
#import "HMTModalShowViewController.h"

@interfaceHMT_AViewController ()
@end

@implementation HMT_AViewController

- (void)viewDidLoad
{
    [superviewDidLoad];
    self.view.backgroundColor = [UIColorredColor];
    
    // 创建一个按钮
    UIButton * button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    button.frame =CGRectMake(100,100,100, 100);
    [button addTarget:self action:@selector(modalShow)forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
// Do any additional setup after loading the view.
}

- (void)modalShow{
    
    HMTModalShowViewController * modalShowVC = [[HMTModalShowViewController alloc]init];

    //模态视图控制器呈现出来时候的视觉效果