My iOS app is built in portrait format and I want to keep it that way. However there is 1 screen which I would like to be in Landscape ONLY, not portrait but can't figure how to do it.
Is there anything that could be advised?
Much appreciated
My iOS app is built in portrait format and I want to keep it that way. However there is 1 screen which I would like to be in Landscape ONLY, not portrait but can't figure how to do it.
Is there anything that could be advised?
Much appreciated
At first you should set up all orientation on Supported Interface Orientation in Xcode project Summary. Then in your appDelegate:
- (NSUInteger) application: (UIApplication*) application supportedInterfaceOrientationsForWindow: (UIWindow*) window
{
NSUInteger orientations = UIInterfaceOrientationMaskAll;
if (self.window.rootViewController)
{
UIViewController* rootViewController = self.window.rootViewController;
UIViewController* presented;
if ([rootViewController isKindOfClass: [UINavigationController class]])
{
presented = [[(UINavigationController*) rootViewController viewControllers] lastObject];
}
else
{
presented = (UIViewController*) rootViewController;
}
orientations = [presented supportedInterfaceOrientations];
}
return orientations;
}
Then in every UIViewController:
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
In which you need other orientation you should change from UIInterfaceOrientationMaskPortrait to UIInterfaceOrientationMaskLandscapeLeft or another.