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.

Était-ce utile?

La 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.

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top