【问题标题】:Can a UITabBarController be a segue.destinationViewController?UITabBarController 可以是 segue.destinationViewController 吗?
【发布时间】: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


【解决方案1】:

正如评论所述,我使用了 self.tabBarController = segue.destinationViewController。

【讨论】:

  • assignement is read only property 使用我的标签栏控制器时出现该错误
【解决方案2】:

谢谢没有

我的情况是将对象值从视图 1 传递到视图 2。

NavControl - ViewController(1)

TabbarControl - NavControl - ViewController(2)

【讨论】:

    猜你喜欢
    • 2011-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-24
    • 2015-05-07
    • 1970-01-01
    相关资源
    最近更新 更多