Open cannyboy opened 12 years ago
I got round the problem by hiding and un-enabling the ng_tabBarItem when the tab bar is initially created:
self.extraViewController.ng_tabBarItem.hidden = YES;
self.extraViewController.ng_tabBarItem.enabled = NO;
.. and then showing / enabling when neccesary.
Hi @cannyboy , I'm curious to hear more about your method. I have an application with an NGTabBarController, and I need to be able to basically redraw the tabbar on the fly in various instances. Can you give me a little more detail about how you went about adding new tabs after the NGTabBarController was already presented?
@amsoell I was not able to add new tabs after it was created. As mentioned above, all I did was hide the ng_tabBarItem when I created the tab bar. When I needed to see it, I just un-hid the item. Since I created the tab bar in my app delegate I first defined a shortcut to my AppDelegate in AppDelegate.h
#define sharedAppDelegate (AppDelegate *) [[UIApplication sharedApplication] delegate]
I also made the vertical tab bar controller a property, as well as the 'hidden' extra view controller
Within AppDelegate.m I had this method:
- (void)showHiddenTab
{
self.extraViewController.ng_tabBarItem.hidden = NO;
self.verticalTabBarController.selectedIndex = self.verticalTabBarController.viewControllers.count-1; // switch to last one
}
.. which I could call from any other view controller like so:
#import "AppDelegate.h"
....
// In a buttons action:
[sharedAppDelegate showHiddenTab];
Thanks, @cannyboy. Not the answer I was hoping for, but I appreciate your time! @myell0w, I would love to know if there is a good / preferred way to update the tabs in an NGTabBarController dynamically.
Is there a way to add tabs during runtime? With UITabBarController, I can do something like this
However, I can't get this working with NGTabBarController, when I change the last line above to :
.. I get this exception:
.. on this line in NGTabTabController, within the method setTabBarItems