문제

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?

도움이 되었습니까?

해결책

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

Then any subclass of that will inherit the behaviour.

다른 팁

Since you mentioned it's a game, then I agree it is a good idea to really make this apply to the entire app.

If you click on your project in the project navigator, then select your target, and in the Summary tab all four orientations are listed and you can enable just the ones you want.

For non-game apps I wouldn't advice this, since there might be one view somewhere which needs another orientation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top