首先遵守“ UITabBarControllerDelegate ”协议
再在- (void)viewDidLoad {}方法中设置代理“ self.tabBarController.delegate = self; ”
最后执行代理方法
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if (_sdCycleScrView.hidden == YES) {
switch (tabBarController.selectedIndex) {
case 0:
{
UINavigationController *nav = tabBarController.viewControllers[0];
if (inputview.hidden == YES) {
inputview.hidden = NO;
nav.tabBarItem.selectedImage = [[UIImage imageNamed:@"[email protected]"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}else{
inputview.hidden = YES;
nav.tabBarItem.selectedImage = [[UIImage imageNamed:@"[email protected]"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}
}
break;
default:
break;
}
}
}