首先遵守“ 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:@"call_2@2x"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}else{
inputview.hidden = YES;
nav.tabBarItem.selectedImage = [[UIImage imageNamed:@"call_3@2x"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}
}
break;
default:
break;
}
}
}