根据电池条状态栏的旋转方向
系统的方法来判断应用的横竖屏。
+ (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;
}