I have a tab bar based application in which I am trying to add tab bar items to the tab bar dynamically using setItems method of the UITabBar.
Here is the code:
[self.tabBarController.tabBar setItems:self.level1TabBarItems animated:YES];
Where self.level1TabBarItems is an NSMutableArray with 4 UITabBarItems in it.
When I run this code, I get an exception from the compiler.
NSInternalInconsistencyException, reason:Directly modifying a tab bar managed by a tab bar controller is not allowed.
I have tried deleting the UITabBarViewController and adding it again but it did not work.
The documentationclearly states that you shouldn’t modify the tab bar directly. UsesetViewControllers:animated:instead.