2015-03-25 64 views
0

我有一个UITabBar控制器与IB使用Relationship-viewControllers设置创建6个选项卡。我希望其中一个选项卡以编程方式根据一组条件调用两个不同的UIViewController中的一个。UITabBar控制器选项卡导航到不同的UIViewControllers

这是可能的,如果是这样,我在哪里实现代码?

编辑

我想,也许我应该尝试和澄清我的问题。我有一个UITabBar控制器。对于其中一个选项卡,我希望它调用UIViewController AUIViewController B,具体取决于给定变量的值。 UIViewController A是使用Relationship-viewControllers的UITabBar控制器的子项,但是UIViewController B不是UITabBarController的子项。也许我试图以错误的方式做到这一点?

或者换句话说,如何根据变量的值,在我的UITabBarController中调用一个选项卡来调用2个不同的UIViewController中的一个?实质上,根据用户的类型,UIView是可互换的菜单屏幕。

回答

0

我想我可能已经解决了这个问题。我的UITabController链接到一个UINavigationController。我已经subclassed UINavigationController viewDidLoad方法,然后使用segues加载正确的UIViewController。

不知道我是否有这个权利 - 我不是100%的UINavigationControllers,但它的工作原理。

-(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]; 
} 

}

相关问题