Skip to content

Adding tabs during runtime #10

@cannyboy

Description

@cannyboy

Is there a way to add tabs during runtime? With UITabBarController, I can do something like this

NSArray *existingTabs = self.tabBarController.viewControllers;
NSMutableArray *mut = [[NSMutableArray alloc] initWithArray:existingTabs];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPhone" bundle:[NSBundle mainBundle]];
self.extraViewController = [[ExtraViewController alloc] init];
self.extraViewController = [storyboard  instantiateViewControllerWithIdentifier:@"ExtraViewController"];
[mut addObject:self.extraViewController];
[self.tabBarController setViewControllers:mut animated:YES];

However, I can't get this working with NGTabBarController, when I change the last line above to :

[self.tabBarController setViewControllers:mut]; // no animated

.. I get this exception:

-[NSNull addTarget:action:forControlEvents:]: unrecognized selector sent to instance

.. on this line in NGTabTabController, within the method setTabBarItems

[item addTarget:self action:@selector(handleItemPressed:) forControlEvents:UIControlEventTouchDown];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions