Skip to content

Instantly share code, notes, and snippets.

@benvium
Created September 24, 2012 14:04
Show Gist options
  • Select an option

  • Save benvium/3776108 to your computer and use it in GitHub Desktop.

Select an option

Save benvium/3776108 to your computer and use it in GitHub Desktop.
Force iOS 6 app portrait only (add to a UIViewController subclass).
/* in iOS 5
// Force app to be portrait-only
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
// iOS 6 interface orientation support. Only rotate on iPad.
- (BOOL)shouldAutorotate {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return NO;
}
}
// iOS 6 interface orientation support. Only rotate on iPad.
- (NSUInteger)supportedInterfaceOrientations {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment