How to create UISplitViewController's portrait behavior in landscape orientations?

南笙酒味 提交于 2019-12-08 05:46:15

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/4180599/how-to-create-uisplitviewcontrollers-portrait-behavior-in-landscape-orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!