Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?

后端 未结 18 1058
北恋
北恋 2020-11-22 16:55

I ran the following code in both iOS 7 and iOS 8:

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landsca         


        
18条回答
  •  佛祖请我去吃肉
    2020-11-22 17:37

    Yes, it's orientation-dependent in iOS8.

    I wrote a Util method to resolve this issue for apps that need to support older versions of the OS.

    + (CGSize)screenSize {
        CGSize screenSize = [UIScreen mainScreen].bounds.size;
        if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
            return CGSizeMake(screenSize.height, screenSize.width);
        }
        return screenSize;
    }
    

提交回复
热议问题