【发布时间】:2012-01-31 19:12:06
【问题描述】:
我有一个带有三个选项卡的 UITabBarController:每个选项卡都是一个嵌入了视图控制器的导航控制器。目前 tabController 是初始视图控制器。我想放置一个介绍视图控制器,其按钮位于 tabController 之前,按钮与 tabController 相连。我正在使用 Xcode 4.2 和故事板。
这可能吗?
在我的 IntroViewController 中,我调用了 prepareForSegue。它不起作用:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"tabSegue"]) {
FirstViewController *firstVC = [[FirstViewController alloc]init];
SecondViewController *secondVC = [[SecondViewController alloc] init];
ThirdViewController *thirdVC = [[ThirdViewController alloc]init];
self.tabBarController = segue.destinationViewController;
UINavigationController *navController1 = [[UINavigationController alloc]initWithRootViewController:firstVC];
UINavigationController *navController2 = [[UINavigationController alloc]initWithRootViewController:secondVC];
UINavigationController *navController3 = [[UINavigationController alloc]initWithRootViewController:thirdVC];
NSArray *tabViewArray = [NSArray arrayWithObjects:navController1,navController2,navController3, nil];
tabBarController.viewControllers = tabViewArray;
}
}
总而言之,你能继续使用 tabBarController 吗?
【问题讨论】:
-
噢!通过放置 self.tabBarController = segue.destinationViewController; 解决了它到最后一行。愿我的错误以某种方式帮助你。
标签: objective-c ios