根据电池条状态栏的方向来判断横竖屏

根据电池条状态栏的旋转方向

系统的方法来判断应用的横竖屏。

+ (CGRect)rectFromWinSizeCurrentWinSize

{

//    get current-device orientation

UIInterfaceOrientationcurrentOrientation = [[UIApplicationsharedApplication]statusBarOrientation];

CGRectAlvinRect = [[UIScreenmainScreen]bounds];

CGFloatAlvinRectWidth = AlvinRect.size.width;

CGFloatAlvinRectHeight = AlvinRect.size.height;

if(UIInterfaceOrientationIsLandscape(currentOrientation)) {

NSLog(@"横版");

if(AlvinRectWidth > AlvinRectHeight) {

floattempSize =0;

tempSize = AlvinRectWidth;

AlvinRectWidth = AlvinRectHeight;

AlvinRectHeight = tempSize;

}

}

else

{

NSLog(@"竖版");

if(AlvinRectWidth < AlvinRectHeight) {

floattempSize =0;

tempSize = AlvinRectWidth;

AlvinRectWidth = AlvinRectHeight;

AlvinRectHeight = tempSize;

}

}

returnAlvinRect;

}

你可能感兴趣的:(根据电池条状态栏的方向来判断横竖屏)