尝试为 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:
对于拆分 View Controller 的两个 Pane 。
要呈现拆分 View 界面,请执行以下操作之一:
属性检查器下的“是初始 View Controller ”框。
我尝试了很多方法,但最后两个陈述中描述的方法从未奏效。
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/