Skip to content

Instantly share code, notes, and snippets.

@sgrankin
Created December 14, 2012 02:26
Show Gist options
  • Save sgrankin/4282046 to your computer and use it in GitHub Desktop.
Save sgrankin/4282046 to your computer and use it in GitHub Desktop.
iOS5/6 shouldAutorotateToInterfaceOrientation compatibility
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([self respondsToSelector:@selector(shouldAutorotate)] &&
[self respondsToSelector:@selector(supportedInterfaceOrientations)]) {
// delegate to iOS6 compatible methods.
return [self shouldAutorotate] && ((1 << interfaceOrientation) & [self supportedInterfaceOrientations]);
}
else {
return [self shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment