Hi,
I have more than 5 tabbar items tabbar controller, the first being 'Home'. The 5 which are shown when the application launches are
first.png
By default Home view is shown. When the user selects any other view I remove home view controller from the tabbar's list of view controller by following code.
Code:
NSMutableArray* newArray = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[newArray removeObject:self];
[self.tabBarController setViewControllers:newArray animated:YES];
This works fine.
Now on all other views there is 'Home' button in the navigation bar which when pressed adds the home view controller in tabbar's view controller array as follows.
Code:
UIViewController *homeViewController=[[HomeViewController alloc]init];
NSMutableArray* newArray = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[newArray insertObject:homeViewController atIndex:0];
[self.tabBarController setViewControllers:newArray animated:YES];
[self.tabBarController setSelectedIndex:0];
This brings back the home screen but the tabbar item is empty as show below.
second.png
How can I fix it?
Thanks