Floyd Resler
Floyd Resler

Reputation: 1786

Stop View Rotation in iOS

Is there a way to stop screen rotation on a specific view? I need to have rotation enabled on my main screen but then disabled once a game mode is chosen. Is this possible?

Upvotes: 0

Views: 44

Answers (2)

Daniel Rinser
Daniel Rinser

Reputation: 8855

I suppose by "on a specific view" you mean "in a specific view controller"? If so, you can just override - [UIViewController supportedInterfaceOrientations] in this one view controller to return only the orientations that you support on that screen:

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

Upvotes: 2

iAnurag
iAnurag

Reputation: 9346

Write this in your AppDelegate

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
  if ([self.window.rootViewController.presentedViewController isKindOfClass: [MainScreen class]])
{
    return UIInterfaceOrientationMaskAll;
}
else return UIInterfaceOrientationMaskPortrait;
}

Upvotes: 0

Related Questions