uiviewcontroller - Storyboard、UIViewController 和 UISplitViewController

标签 uiviewcontroller uisplitviewcontroller storyboard segue

尝试为 iPad 制作基于 Storyboard的应用程序。在其中,我需要从开始屏幕 (UIViewController) 过渡到主屏幕 (UISplitViewController),然后再到全屏 View (再次是 UIViewController)。
我在网络上看到了许多讨论(至少有几个 - 在 stackoverflow 上),指出 UISplitViewController 除了作为 RootViewController 之外,不能以任何其他方式用于基于 Storyboard 的应用程序。一些线程包含变通方法,还有替代的 splitview ( https://github.com/mattgemmell/MGSplitViewController ) 来解决这个问题。
但我无法理解的是,为什么 Apple 文档中的说法恰恰相反。这是link到 Apple 的 iOS 5.0 库中的章节。它指出:

使用 Storyboard 创建分屏 Controller
要将拆分 View Controller 添加到应用程序的 Storyboard:

  • 打开应用程序的主 Storyboard。
  • 将拆分 View Controller 拖出库。这也会创建 View Controller
    对于拆分 View Controller 的两个 Pane 。
  • 对于每个拆分 View Controller 包含的 View Controller ,使用身份检查器设置 View Controller 的类名。

  • 要呈现拆分 View 界面,​​请执行以下操作之一:
  • 通过选择场景并检查将其显示为第一个场景
    属性检查器下的“是初始 View Controller ”框。
  • 通过向其添加模态转场,从另一个场景显示它。
  • 通过调用 performSegueWithIdentifier:sender: 方法启动模态转场,以编程方式显示它。

  • 我尝试了很多方法,但最后两个陈述中描述的方法从未奏效。
    modal segue 和 performSegue... 都失败并出现众所周知的错误:

    "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a Split View Controllers modally..."


    有谁能解释一下吗?这是 XCODE/iOS 5.0 中的错误还是文档中的错误?
    问候,
    彼得

    最佳答案

    根据这个苹果article ,拆分 View Controller 必须是根。这是一个片段:

    A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window. The panes of your split-view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface. Split view controllers cannot be presented modally.

    关于uiviewcontroller - Storyboard、UIViewController 和 UISplitViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9044586/

    相关文章:

    iphone - .h 实现文件无法识别我的 UIViewController

    ios - Split View Controller 只显示一个 childviewcontroller

    ios - UISplitViewController - 用作滑出式菜单

    ios - Xcode Storyboard : Why does the iPad storyboard show iPhone sized views?

    ios - 如何检查 swift 2.2 中是否存在 iphone 控制中心?

    ios - segue完成后如何执行一些代码?

    ios - 设备与模拟器上的 UILabel 位置不一致

    swift - 如何放松回家,然后一次行动继续前进

    ios - 新创建的 UIViewController 在 Storyboard中不可用

    iphone - 在 Split View Controller 中选择主视图选项卡上的更改详细 View