objective-c - 选项卡栏 Controller 未正确显示

标签 objective-c ios cocoa-touch ios5

我正在尝试将 Tab Bar Controller 连接到我的应用程序的现有部分,但是当我这样做时它“出现故障”。

但是,当我独立运行 Tab Bar Controller 部件作为初始 View Controller 时,它可以正常工作,如下图所示:

enter image description here

这是应用程序运行时的样子(正确行为):

enter image description here

然而,当我从我的主应用程序转到这个标签栏 Controller 时,它是这样的:

enter image description here

我的主应用是这样的:

ScrollView 包含

  • 用户界面 View 1
  • 用户界面 View 2
  • 用户界面 View 3
  • UIView x

每个 View 都做一些与这个标签栏 Controller 无关的事情。只有一个 View view x 尝试“访问”选项卡栏 Controller 并在那里显示一些数据,但事实并非如此。有什么想法吗?

我将此选项卡栏 Controller 标识符设置为测试,从我的视角 x 来看,我是这样做的:

UITabBarController *newViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];
        [self.view addSubview:newViewController.view];

编辑:

整个应用:

enter image description here

我正在以编程方式创建 View 。这就是为什么我与标签栏 Controller 没有任何关系/转场。

解决方案:

改变:

UITabBarController *newViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];
            [self.view addSubview:newViewController.view];

收件人:

UITabBarController *newViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];
        [self addChildViewController:newViewController];
        [self.view addSubview:newViewController.view];

最佳答案

您需要为导航 Controller 设置一个 Root View Controller

关于objective-c - 选项卡栏 Controller 未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9465562/

相关文章:

ios - 在 UITackView 中使用自定义 xib

iOS RestKit block

ios - 如何进行自定义 View Controller 转换,其中一部分是 UIView animateWithDuration 而另一部分是 transitionFromView?

iphone - 在 iPhone 操作系统上检测文件创建日期?

ios - EXC_BAD_ACCESS 但 NSZombies 从未触发,如何调试?

iphone - UIWebView - 如何识别 "last"webViewDidFinishLoad 消息?

ios - Swift println() 在编写代码时不显示自动完成选项

ios - iOS6 中的社交分享面板

ios - 如何禁用 UITableViewCell 但仍与附属 View (即 UISwitch)进行交互

objective-c - 如何在协议(protocol)中发布 static void NSString?