Skip to content

Commit bb10061

Browse files
committed
Merge pull request #8 from gzucm/pull1.0.0
deviceSize method consider landscape orientation status
2 parents b90fa03 + da6f882 commit bb10061

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

SDiPhoneVersion/SDiPhoneVersion.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ +(DeviceVersion)deviceVersion {
7272

7373
+(DeviceSize)deviceSize {
7474

75-
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
75+
CGFloat screenHeight = ({
76+
// consider landscape orientation status
77+
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
78+
BOOL isLandscape = (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight);
79+
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
80+
CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
81+
screenHeight = isLandscape ? screenWidth : screenHeight;
82+
});
7683
if (screenHeight == 480)
7784
return iPhone35inch;
7885
else if(screenHeight == 568)

0 commit comments

Comments
 (0)