iOS

iOS 拦截TabBarItem点击事件

2017-05-23  本文已影响1426人  人间微风

在UITabBarControllerDelegate 的代理方法,

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController NS_AVAILABLE_IOS(3_0);中做自己的操作;

如果不想进入点击的控制器中,可以return No;

例如

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController NS_AVAILABLE_IOS(3_0) {

BaseNaviController *navCtrl = (BaseNaviController *)viewController;

UIViewController *rootCtrl = navCtrl.topViewController;

if([rootCtrl isKindOfClass:[RegistViewController class]]) {

[self _registAction];

BaseNaviController *navCtrl2 = self.viewControllers[0];

self.selectedViewController = navCtrl2;

self.selectedIndex = 0;

return NO;

}

return YES;

}

上一篇下一篇

猜你喜欢

热点阅读