Created
June 29, 2013 15:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(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