1

I want to change device orientation for only one UiViewController. My first UiViewController's name is VideoLaunch. I want Landscape orientation in this UiViewController firstly. When I pass another uiviewcontroller I change a static value which name is "is" to different from nil. When i run in debug mode i see

else return UIInterfaceOrientationMaskPortrait

this line runs. But orientation doesn't change.

AppDelegate.m

 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {   
    if([VideoLaunch is] == nil)
        return UIInterfaceOrientationMaskLandscape;

    else return UIInterfaceOrientationMaskPortrait;
 }
Meryem Uysal
  • 191
  • 1
  • 2
  • 13
  • 1
    check this http://stackoverflow.com/questions/27009979/ios-lock-a-specific-uiviewcontroller-to-a-specific-orientation – Rishab Mar 02 '16 at 13:04

1 Answers1

4

You need to override the following method

- (BOOL)shouldAutoRotate

return YES for the one where you want allow rotation.

Then, also override supportedDeviceOrientations and specify what you want in there. For example:

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

and make sure that you allowed orientations correctly in your target's General settings.

Sachin Patil
  • 353
  • 1
  • 13