0

I have a UITabBar controller with 6 tabs created in IB set up using Relationship-viewControllers. I would like one of the tabs to programmatically call one of two different UIViewControllers depending on a set of criteria.

Is this possible, and if so, where do I implement the code?

Edit

I think I should maybe try and clarify my problem. I have a UITabBar controller. For one of the tabs I want it to call either UIViewController A or UIViewController B depending on the value of a given variable. UIViewController A is a child of the UITabBar controller using Relationship-viewControllers but UIViewController B is not a child of the UITabBarController. Perhaps I am trying to do this the wrong way?

Or to put it differently, how can I get a single tab in my UITabBarController call one of 2 different UIViewControllers depending on the value of a variable? In essence, the UIViews are interchangeable menu screens depending on the type of user.

Mark__C
  • 825
  • 1
  • 13
  • 24

1 Answers1

0

I think I may have solved this. My UITabController links to a UINavigationController. I have subclassed the UINavigationController viewDidLoad method and then used segues to load the correct UIViewController.

Not sure if I have this right - I'm not 100% on UINavigationControllers but it works.

-(void)viewDidLoad{
[super viewDidLoad];

PFUser *currentUser = [PFUser currentUser];
NSString *userType = [currentUser valueForKey:@"UserType"];

if([userType isEqualToString:@"User"]){
    [self performSegueWithIdentifier:@"userContribute" sender:self];
} else {
    [self performSegueWithIdentifier:@"bizContribute" sender:self];
}

}

Mark__C
  • 825
  • 1
  • 13
  • 24