tabbar禁止連續點選,或push過後,點選tabbar禁止返回
阿新 • • 發佈:2019-01-05
tabbar禁止連續點選,或push過後,禁止點選tabbar後返回
根檢視下面加上
#pragma mark - UITabBarDelegate
- (BOOL)tabBarController:(UITabBarController*)tabBarController shouldSelectViewController:(UIViewController*)viewController {
if([viewController isKindOfClass:[UINavigationController class]]) {
UINavigationController* nav = (UINavigationController*)viewController;
// 當UINavigationController中viewControllers大於1或當前頁面正在被選中時,當前頁tabbar禁止再點選
if([nav.viewControllers count] >1 && tabBarController.selectedViewController == viewController) {
return NO;
}
}
return YES;
}