Question

I have now been stuck on this problem for more then 2 weeks! In my project, I have 1 single ViewController(slide) I want to enable both landscape and portrait in. The rest of all controllers/views(slides) I want to enable portrait-mode only.

The tricky part is, the "ViewController" I am referring to is connected to both NavigationControllers and TabBarControllers. See the scheme below where the ViewController I want to enable both landscape/portrait is named: ReferredViewController.

TabBarController ----> NavigationController ----> FristViewController --(push event)--> ReferredViewController

So far I have tried to make a CATEGORY for both NavigationControllers and TabBarControllers. But since my NavigationControllers and TabBarControllers are placed at the very start of the project this will set the rules for the whole project. My ReferredViewController is placed at the end or in the middle of the projects "storyboard". I have tried to set the rules by code aswell for the single ReferredViewController without any success.

So far my best shot is to change the event between FirstViewController and ReferredViewController from "push" to "modal". ReferredViewController can then rotate both portrait/landscape and the rest of the project is locked in portrait. BUT, as you may know all navigations will be lost and the user will become stuck at that single slide.

One thing I also wonder, is it possible to show NavigationControllers in a ModalViewController? I have not tried/tested this scenario all possible ways but a confirmation on the matter would be appreciated.

If you have any smart tips or moves for the scheme above, please I need all help I can get, I am so frustrated with not being able to solve this! /regards

Was it helpful?

Solution

The problem is that you are doing things that are not suported by apples design. That problems with the tab bar roattion are well known, and you find here stackoverflow many post about that topic.
In apples design strategy the top most controller must allow both rotations, only the sub controllers can reduce that to one orientation.
if you want it the other way, the top most support portrait, and the childs both, the you are on your own.
These things that are not supoorted by apple are verry time consuming.
i was in the situation, that didRotate..() was not called. i finnally solved it by self rotating the view using CGtransform..., which info I got here in stackoverflow.

To solve that, use two view controllers, one which allows both orientations, one which allows only one. to avoid duplicate code, you may call common code from an inherited class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top