سؤال

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