Skip to content

Instantly share code, notes, and snippets.

@troyharris
Created June 29, 2013 15:26
Show Gist options
  • Save troyharris/5891542 to your computer and use it in GitHub Desktop.
Save troyharris/5891542 to your computer and use it in GitHub Desktop.
Methods for getting the real height and width of a device based on orientation
+(CGFloat)getRealDeviceWidth {
CGFloat deviceWidth;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if(UIInterfaceOrientationIsLandscape(orientation)) {
deviceWidth = [UIScreen mainScreen].bounds.size.height;
} else {
deviceWidth = [UIScreen mainScreen].bounds.size.width;
}
return deviceWidth;
}
+(CGFloat)getRealDeviceHeight {
CGFloat deviceHeight;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if(UIInterfaceOrientationIsLandscape(orientation)) {
deviceHeight = [UIScreen mainScreen].bounds.size.width;
} else {
deviceHeight = [UIScreen mainScreen].bounds.size.height;
}
return deviceHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment