3

I am looking to create a view controller which displays in both portrait and landscape.The app currently runs in only portrait. Before you consider marking as duplicate (I've exhausted many a search on here), hear me out:

The app displays a set of maps from our web server, the URLs do not change but the content changes daily (always a png, pdf, or mp4 extension). These products are accessed through two different means:

Tabviewcont>Navviewcont>viewcont>viewcont(which displays the web content) Tabviewcont>navviewcont>collviewcont>collviewcont>viewcont(which displays the web content)

I have tried: subclassing navcont by creating a new one and setting the webviewcont as the root and then overriding methods, using CGAFFINETRANSFORM, and overriding supportedorientations and preferredorientations in each view controller, UIImageView (brick wall because I forgot I have an mp4).

What I am trying to accomplish: Webviewcontrollers capable of rotating in portrait or landscape while other viewcontrollers remain in portrait.

Am open to any suggestion. Looked at Facebook and it seems they lock the feed display to portrait but when you click on an image from within your feed, you can view it in either portrait or landscape.

jclark754
  • 914
  • 2
  • 12
  • 30
  • Have you looked at this: http://stackoverflow.com/questions/12447552/ios6-supportedinterfaceorientations-not-working-is-invoked-but-the-interface-s – Nate Lee Jun 28 '14 at 20:27

1 Answers1

0

The smoothest, and most framework-correct way to achieve this is to present the view controller you wish rotatable modally, and in - (NSUInteger)supportedInterfaceOrientations pass the correct mask of supported orientation. This is how Facebook achieves this.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
  • Greetings Leo. I have read your other answers on this matter...your solution has gotten me the furthest thus far. However, I noticed in the example you generously provided via mediafire that your first controller was capable of rotating in portrait or landscape. That was yesterday and I was pretty fried...is that view capable of being restricted to just portrait orientation similar to LNViewController2? Reference: http://stackoverflow.com/questions/15947349/how-to-handle-different-orientations-in-ios/16022631#16022631 – jclark754 Jun 28 '14 at 20:53
  • Yes. In fact, I think in my example, the root stack is dependent on the project settings for rotation. So if only landscape is allowed, it will not rotate to portrait. – Léo Natan Jun 28 '14 at 21:07
  • Ay yes, I am actually describing the first view controller http://imgur.com/HBFcGLC. The second one (which is forced to landscape) is the red one if you recall. In your example, this very first view controller that is presented is presented in portrait but can rotate to landscape. Your second viewcontroller is forced to landscape and cannot rotate to portrait. In the case of the first view controller, if I wanted to lock it in portrait, would I have to create another navcont class to handle it? – jclark754 Jun 28 '14 at 21:17
  • Seems to be the case, dang I was hoping I could get away with not creating classes for these otherwise hollow navcontrollers – jclark754 Jun 28 '14 at 21:20
  • No, in project settings, set supported orientation as just the landscape modes. – Léo Natan Jun 28 '14 at 21:21
  • In your test project, the first view rotates (presented as portrait but is able to rotate to landscape).This is with project settings >portrait and both landscapes selected. Deselecting portrait forces all views to landscape. I would like to have that first view displayed in only portrait and the second view in landscape – jclark754 Jun 28 '14 at 21:36
  • Ok, so enable just portrait in project settings. If your second VC supports landscape, it will display in land. – Léo Natan Jun 28 '14 at 21:41
  • It does not work, the only thing that seems to work to lock the first view controller to portrait is to implement the provided methods into its parent view...meaning I'd have to give a nav controller to every scene. Selecting only portrait, regardless of what the second VC supports, only displays the second VC in portrait. – jclark754 Jun 28 '14 at 21:49
  • I will take a look soon. – Léo Natan Jun 29 '14 at 04:47