I am using TabbarController. When I am in the first tab all other tabItem in a disable mode and I have one button in the first tab viewcontroller, on clicking that button it should move to the second tabitem. I have implemented setselectedindex but no change in that.
- (void)clinicBtnTapped
{
enteredSecondTab==YES;
CustomTabBar *tabbar=[[CustomTabBar alloc] init];
[self.tabBarController setSelectedIndex:1];
AppSys_SplitView *apptmtSys=[[AppSys_SplitView alloc] init];
[tabbar tabBarController:tabbar.tabBarController shouldSelectViewController:apptmtSys];
tabindex=1;
[tabbar tabBarController:tabbar.tabBarController didSelectViewController:appsys];
}
In Should Select ViewController
- (BOOL)tabBarController:(UITabBarController *)tabBarControlle shouldSelectViewController:(UIViewController *)viewController{
tabindex = [[tabBarControlle viewControllers] indexOfObject:viewController];
NSLog(@"index %d",index);
for(UIImageView *view in[self.view subviews]){
[view removeFromSuperview];
}
tabBarController.imgV.frame=CGRectMake(0, 717, 1024, 53);
switch (tabindex) {
case 0:
enteredFirstTab = YES;
enteredSecondTab = NO;
enteredThirdTab = NO;
enteredFourthTab = NO;
tabBarController.imgV.image=[UIImage imageNamed:@"select_TrackClinic_icon.png"];
return YES;
break;
case 1:
if(enteredSecondTab == YES)
{
enteredFirstTab = NO;
enteredSecondTab = YES;
enteredThirdTab = NO;
enteredFourthTab = NO;
tabBarController.imgV.image=[UIImage imageNamed:@"select_Application_icon.png"];
return YES;
}
else
{
return YES;
}
break;
case 2:
return NO;
enteredFirstTab = NO;
enteredSecondTab = NO;
enteredThirdTab = YES;
enteredFourthTab = NO;
tabBarController.imgV.image=[UIImage imageNamed:@"select_regularOnsite_icon.png"];
break;
case 3:
return NO;
enteredFirstTab = NO;
enteredSecondTab = NO;
enteredThirdTab = NO;
enteredFourthTab = YES;
tabBarController.imgV.image=[UIImage imageNamed:@"select_resultUpdate_icon.png"];
break;
default:
break;
}
}
Here I can give you some tutorial for implementing the custom tabbar
Delegate.h file
Delegate.m file
Following code put into viewcontroller.m
This code may helping to development.