Search code examples
objective-cioscocoa-touchuiviewcontrollerdevice-orientation

Make landscape the only autorotate orientation for all view controllers at once


I know that I have to add this

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

to a view controller in order to make that specific screen lock in landscape mode, but do I have to do this for every view controller? Is there a way to just do a master lock that would apply to all view controllers?


Solution

  • You can create you own subclass of UIViewController, which implements -shouldAutorotateToInterfaceOrientation:.

    Then any subclass of that will inherit the behaviour.