19

每当我尝试以模态方式呈现 UISplitViewController 时,应用程序就会崩溃。因此它必须始终是根视图控制器。谁能证实这一点?

4

5 回答 5

21

来自Apple iPad 编程指南

拆分视图控制器的视图应始终安装为应用程序窗口的根视图。您永远不应该在导航或标签栏界面内显示拆分视图。

所以是的,您不能在主应用程序窗口(包括模态)之外显示拆分视图。

编辑

上面文档的链接不再讨论这个话题。现在可以在 Apple 的iOS 视图控制器目录中找到相关讨论,其中指出:

拆分视图控制器必须始终是您创建的任何界面的根。换句话说,您必须始终将 UISplitViewController 对象中的视图安装为应用程序窗口的根视图。[...] 拆分视图控制器不能以模态方式呈现。

于 2010-04-05T17:38:08.307 回答
3

I got the same problem with the same error when I tried to segue from a regular content view controller (ie. no problem segueing from a tab controller or a nav controller).

Fortunately I found a way to circumvent this by inserting a nav controller between the VC and the split view controller. In other word, segue from the VC to a nav controller, then draw a relationship connection between the nav controller and the split view controller. In this way, instantiating a split view still requires no coding.

于 2012-12-26T14:03:35.957 回答
2

当然你可以UISplitViewController不使用它作为根视图控制器来使用它。在我的项目中,我这样使用它:

  1. 以模态方法显示我自己的视图控制器:
[自我presentModalViewController:mainViewController动画:YES];
  1. 在 mainViewController 中,我有
UISplitViewController *splitViewController;

在 中- (void)viewDidLoad,设置splitViewController.viewmainViewController.view

splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];
self.view = splitViewController.view;
于 2011-02-08T14:44:44.423 回答
1

UISplitController 可以安装在 UITabBarController 下。我做。只需在这个论坛上使用搜索 - 我找到了至少一个好的软件示例。

于 2012-01-11T08:45:28.863 回答
0

是的,你必须使用 RootViewController,它应该继承自 UITableViewController。你可以看看这个教程

于 2013-02-07T10:49:14.047 回答