如何在横向方向创建UISplitViewController的肖像行为? [英] How to create UISplitViewController's portrait behavior in landscape orientations?

查看:97
本文介绍了如何在横向方向创建UISplitViewController的肖像行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一个我见过在某些iPad应用程序中实现的解决方案,其中似乎是 UISplitViewController 不会显示停靠在左侧的主视图在横向方向。相反,行为在横向和纵向完全相同, UIToolbar 左侧的 UIBarButtonItem 在屏幕顶部,使用主视图控制器的视图显示 UIPopoverController 。这会显示一些菜单选项,当选中它们时,会在详细视图中启动新的 UIViewController - 派生的类。

I'm trying to find a solution I've seen implemented in some iPad apps where what appears to be a UISplitViewController does not display the master view docked to the left in landscape orientation. Instead, the behavior is exactly the same in landscape as in portrait, with a UIBarButtonItem on the left side of a UIToolbar at the top of the screen bringing up a UIPopoverController with the master view controller's view. This presents some menu options that, when selected, appear to launch new UIViewController-derived classes into the detail view.

我正在开发的应用程序需要利用尽可能多的屏幕空间,并且使用左侧停靠的菜单选项的主视图不会增加太多价值;它实际上阻碍了应用程序。

The app I'm working on needs to take advantage of as much screen real estate as possible and having the master view with the menu options docked to the left side doesn't add much value; it actually hinders the app.

所以我实际上要做的事情是双重的:

So actually what I'm trying to do is two-fold:


  1. 以横向方式取消停靠的主视图

  2. 在主视图中选择一行(菜单选项)加载新的 UIViewController - 在详细视图中输入了类。

  1. Suppress the docked master view in landscape orientation
  2. Have the selection of a row (menu option) in the master view load a new UIViewController-derived class into the detail view.

我分别看到了各自的例子:

I've seen examples of each by themselves, respectively:


  1. http://vimeo.com / 13054813 (隐藏UISplitViewController的根视图)

  2. http:/ /bit.ly/aypcr0 (来自Apple的MultipleDetailViews代码示例)

  1. http://vimeo.com/13054813 (Hiding the Root View of a UISplitViewController)
  2. http://bit.ly/aypcr0 (MultipleDetailViews code example from Apple)

然而,我似乎无法同时获得两者这些合作。

However, I can't seem to get both of these working together.

使用这种方法的原因是我有多个 UIViewController - 派生的类,我想在选择适当的菜单选项。我可以实例化它们并将它们的视图添加到现有的详细视图中,它们将显示正常。问题是除了 viewDidLoad 之外,没有任何UIViewController生命周期方法被调用(例如 viewWillAppear: viewDidUnload 等)。这还包括方向更改,这对应用程序来说是个大问题。似乎只有 UIViewController -derived类的行为就像 UIViewController 一样,它被添加为子视图应用程序的 UIWindow ,或容器类(如 UINavigationController UISplitViewController )。

The reason for using this approach is that I have multiple UIViewController-derived classes that I want to display when the appropriate menu option is selected. I could just instantiate them and add their views to the existing detail view and they would display fine. The problem is that none of the UIViewController lifecycle methods ever get called besides viewDidLoad (e.g. viewWillAppear:, viewDidUnload, etc.). This also includes orientation changes, and this is a big problem for the app. It seems that the only times a UIViewController-derived class acts like a UIViewController is when it is added as a subview of the app's UIWindow, or to a container class (like UINavigationController or UISplitViewController).

我是否使用 UISplitViewController 走正确路径,还是有更好的解决方案?

Am I going down the right path with the UISplitViewController, or is there a better solution?

提前感谢您的所有帮助!

Thanks for all of your help in advance!

Justin

推荐答案

这是一个很好的UISplitViewController替代品,具有您想要的功能(以及更多)。它是真正的UISplitViewConroller的直接下降替代品。

This is a good UISplitViewController replacement that has the features you want (and more). It is a direct "drop in" replacement for the real UISplitViewConroller.

http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad

这篇关于如何在横向方向创建UISplitViewController的肖像行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆