Application is portrait locked but there is this only video screen when I need to allow landscape orientation as well. My implementation is as follows:
in project file
Created custom navigation controller and overridden following methods :
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger supportedOrientation = [[self.viewControllers lastObject] supportedInterfaceOrientations];
return supportedOrientation;
}
Now lets say in application I have 4 view controllers as follows :
- Home view controller (portrait locked)
- List view controller (portrait locked)
- Video view controller (portrait + landscape)
- Settings view controller (portrait locked)
So in each view controller overridden
- (NSUInteger)supportedInterfaceOrientations
{
}
and returned UIInterfaceOrientationMaskPortrait
or UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight
depending on the view controller support.
I am using storyboard
and Xcode 5.0.2
Our custom Navigation controller is root view controller. Home is on top of it, and in view will appear depending on count of some maintained list we either stay or navigate to List View controller using push segue.
From Video and setting view controller we have unwind segue which is connected to Home View controller.
If I go from portrait(Video) to setting, it remains portrait locked as expected.
Problems :
- If video is in landscape and then we move to Settings, settings is launched in landscape mode. If rotated once, then it becomes locked to portrait.
- In launch sequence as per implementation from Home if list count is 0 we move to List view controller. In this case viewWillAppear of List controller is called properly. But, lets say we are on Video in landscape and unwind segue is called, we are properly navigated from Home n then to List View Controller but viewWillAppear is not called in this particular scenario.
Some has suggested to implement shoudAutorotate
as well. Have tried to return NO from portrait screens and YES from video View Controller (Trivially shouldAutorotate
is implemented for custom navigation controller like supportedInterfaceOrientations
implementation). But with this if steps from Problem 1 are followed, setting screen gets locked to landscape.
If there is any other suggestion? or is something missing?