如何在横向方向上创建 UISplitViewController 的纵向行为?

发布于 2024-10-02 14:34:49 字数 1272 浏览 2 评论 0原文

我正在尝试找到一个在某些 iPad 应用程序中实现的解决方案,其中看似 UISplitViewController 的内容不会以横向方式显示停靠在左侧的主视图。相反,横向和纵向的行为完全相同,屏幕顶部 UIToolbar 左侧有一个 UIBarButtonItem,会弹出一个 UIPopoverController 与主视图控制器的视图。这提供了一些菜单选项,选择这些选项后,似乎会将新的 UIViewController 派生类启动到详细信息视图中。

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

所以实际上我想做的是两部分:

  1. 抑制横向停靠的主视图
  2. 在主视图中选择一行(菜单选项)加载一个新的 UIViewController 派生类进入详细视图。

我分别看到了每个例子:

  1. http://vimeo.com/13054813 (隐藏根UISplitViewController 的视图)
  2. http://bit.ly/aypcr0 (Apple 的 MultipleDetailViews 代码示例)

但是,我可以似乎没有让这两者一起工作。

使用此方法的原因是我有多个 UIViewController 派生类,我希望在选择适当的菜单选项时显示这些类。我可以实例化它们并将它们的视图添加到现有的详细视图中,它们就会显示得很好。问题是,除了 viewDidLoad 之外,没有任何 UIViewController 生命周期方法被调用(例如 viewWillAppear:、viewDidUnload 等)。这还包括方向变化,这对应用程序来说是一个大问题。似乎 UIViewController 派生类唯一像 UIViewController 一样工作的时候是当它被添加为应用程序的 UIWindow 的子视图时,或者容器类(如 UINavigationController 或 UISplitViewController)。

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

提前感谢您的所有帮助!

贾斯汀

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. 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 (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.

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).

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小巷里的女流氓 2024-10-09 14:34:49

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文