Skip to content

Instantly share code, notes, and snippets.

@justin
Created June 14, 2014 12:52
Show Gist options
  • Save justin/aafce8a85ee9b0595494 to your computer and use it in GitHub Desktop.
Save justin/aafce8a85ee9b0595494 to your computer and use it in GitHub Desktop.
The old way of handling orientation and different devices
UIDevice *device = [UIDevice currentDevice];
UIDeviceOrientation currentOrientation = device.orientation;
BOOL isPhone = (device.userInterfaceIdiom == UIUserInterfaceIdiomPhone);
BOOL isTallPhone = ([[UIScreen mainScreen] bounds].size.height == 568.0);
if (UIDeviceOrientationIsPortrait(currentOrientation) == YES)
{
// Do Portrait Things
if (isPhone == YES)
{
// Do Portrait Phone Things
// Don't deny you've done this at least once.
if (isTallPhone)
{
// iPhone 5+
}
else
{
// Old phones
}
}
else
{
// Do Portrait iPad things.
}
}
else
{
// Do Landscape Things.
if (isPhone == YES)
{
// Do Landscape Phone Things
}
else
{
// Do Landscape iPad things.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment