Skip to content

Instantly share code, notes, and snippets.

@DougFischer
Created October 9, 2013 05:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DougFischer/6896488 to your computer and use it in GitHub Desktop.
Save DougFischer/6896488 to your computer and use it in GitHub Desktop.
On iOS6+, the orientation of modal view controllers is handled by the view controller who present them. If you're using UITabBarController, it can be a little confusing, since you need to add presenting view controller some code to handle the modal controller's visibility. This code snippet shows how to have all UIViewControllers orientations (p…
#pragma mark -
#pragma mark UIApplication Delegate
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)pWindow {
UITabBarController *tabCtrl = (UITabBarController *)self.window.rootViewController;
//Check if there's a modal view controller on screen (dismissing modal view controllers are ignored)
if (tabCtrl.selectedViewController.presentedViewController && !tabCtrl.selectedViewController.presentedViewController.isBeingDismissed) {
return tabCtrl.selectedViewController.presentedViewController.supportedInterfaceOrientations;
}
return UIInterfaceOrientationMaskLandscape;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment