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

后端 未结 18 997
北恋
北恋 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:41

    Thats what I used to calculate the correct rect:

    UIScreen* const mainScreen = [UIScreen mainScreen];
    CGRect rect = [mainScreen bounds];
    #ifdef __IPHONE_8_0
    if ([mainScreen respondsToSelector:@selector(coordinateSpace)])
    {
        if ([mainScreen respondsToSelector:@selector(fixedCoordinateSpace)])
        {
            id tmpCoordSpace = [mainScreen coordinateSpace];
            id tmpFixedCoordSpace = [mainScreen fixedCoordinateSpace];
    
            if ([tmpCoordSpace respondsToSelector:@selector(convertRect:toCoordinateSpace:)])
            {
                rect = [tmpCoordSpace convertRect:rect toCoordinateSpace: tmpFixedCoordSpace];
            }
        }
    }
    #endif
    

提交回复
热议问题