Question

Is there a way to restrict view rotation to only one view controller? For example the rest of the app stays in portrait mode but one view can be in either landscape or portrait mode.

Was it helpful?

Solution

Use this delegate method to control the rotation,

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        // Return YES for supported orientations
        return YES;
    }
    else
    {
        return NO;
    }
}

return YES for the orientations you want to support and NO for others. You can implement this in all the view controllers.

OTHER TIPS

You can implement the shouldAutorotateToInterfaceOrientation: method of each UIViewController. Returning YES for the orientations you want a given view controller to support will yield the desired result.

See the UIViewController docs.

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