0

I am using XCode 7 & Objective C. My requirement is to show a viewcontroller in landscape mode. I am able to do it successfully using the following methods.The situation in the iPhone app is that my first View Controller is Portrait. It has a button. When we click on it, the Unity 3D app should open in Landscape. I want to keep a loading view in between.

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{

if(self.isGoingToVrView == NO)
{
    loadingLabel.text = @"Rotate your device to begin";

    NSLog(@"Return Portrait");

    return UIInterfaceOrientationMaskPortrait;

}
else{

    landscapeView.frame = CGRectMake(0, 0,667.000000, 375.000000);

    loadingLabel.text = @"Loading...";

    NSLog(@"Return Landscape");

    [UIViewController attemptRotationToDeviceOrientation];

    return UIInterfaceOrientationMaskLandscapeRight;
}}

- (BOOL)shouldAutorotate{

NSLog(@"%s",__PRETTY_FUNCTION__);
return YES;}

But the problem is that it does not go to Landscape & remains stuck in Portrait if someone has switched On the Portrait Orientation Lock : ON from the Control Center as shown in this screenshot. Let me know if anyone knows how to overcome this.

enter image description here

iOS_Passion
  • 788
  • 1
  • 7
  • 17
  • Do you want the app to only work in landscape the entire time? And read those texts... – Wyetro Jul 13 '16 at 17:00
  • No not always just for this view controller – iOS_Passion Jul 13 '16 at 17:05
  • Possible duplicate of [iOS 6: How do I restrict some views to portrait and allow others to rotate?](http://stackoverflow.com/questions/12630359/ios-6-how-do-i-restrict-some-views-to-portrait-and-allow-others-to-rotate) – Wyetro Jul 13 '16 at 17:08
  • 2
    @WMios But isn't the question about the Portrait Lock setting in the control center? – matt Jul 13 '16 at 17:11
  • If you figure out how to do it, I think you will have found an OS bug. – danh Jul 13 '16 at 17:17
  • @WMios : As Matt stated - the question is about Portrait Lock Setting in the control center and handling Landscape orientation for a view controller in such a situation. – iOS_Passion Jul 14 '16 at 03:02
  • @iOS_Passion, yeah I saw, just disregard my comment and read those 485 texts ;) – Wyetro Jul 14 '16 at 03:25

0 Answers0