5

In my app, i have 4 tab bar items. Iam adding these 4 tab bar items in XIB file.

Initially i have to show 3 tab bar items and after sync i have to show 4th tab bar item in my app. So for this, i am hiding 4th Tab bar item using following code.

[[[self.tabBarController.tabBar subviews] objectAtIndex:03 setHidden:YES];

The tab item is hiding but i am having blank space in place of the hidden item. Is there any chance to align other 3 items in full tab bar. The thing is i dont want to show blank space or empty space in tab bar.

Thanks Jithen

Coder
  • 1,661
  • 4
  • 27
  • 50
  • check it may be it help for you http://deskiphone.blogspot.com/2011/09/add-and-remove-tabbar-item-run-time.html – jamil Apr 13 '13 at 09:35

1 Answers1

6

If you want to get the items of the tabBar rearranged you have to remove the controller from the controllers list, not hide it. You can use this code to achieve this:

NSMutableArray *controllers = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[controllers removeObjectAtIndex:3];
[self.tabBarController setViewControllers:controllers animated:YES];
tkanzakic
  • 5,499
  • 16
  • 34
  • 41
  • Is it not possible to align the remaining 3 tab bar items in full tab bar without removing object? – Coder Apr 13 '13 at 09:05
  • 1
    I guest not, you have to remove the object, if you need it later you can keep a copy of the full array – tkanzakic Apr 13 '13 at 09:26