UITabBarController点击UITabBarItem 禁止跳转

基类里面.m

@interface BaseViewController ()
 
@end

//判断是否跳转
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
    if ([viewController.tabBarItem.title isEqualToString:@"我的"]) {
        return NO;
    }else{
        return YES;
    }
}

- (void)viewDidLoad{
    [super viewDidLoad];

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UITabBarController *tabViewController = (UITabBarController *) appDelegate.window.rootViewController;
    tabViewController.delegate = self;
}


你可能感兴趣的:(UITabBarController点击UITabBarItem 禁止跳转)