【问题标题】:iOS 7 Class size compatibilityiOS 7 班级大小兼容性
【发布时间】:2015-03-05 09:13:51
【问题描述】:

我已阅读有关类大小及其向后兼容性的 Apple 文档。

它说,大多数类都与 iOS 7 兼容,主要限制是 iPhone 的 Compact Height 值。

有没有人设法将 iPhone 横向与纵向分开?它非常适合将 iPad 与 iPhone 分开,但我没有得到任何关于 iPhone 的结果。

我试过了: 纵向:wCompact - hRegular 横向(默认):任意 - 任意

它总是在两个方向上都使用纵向版本。

【问题讨论】:

    标签: ios iphone xcode interface-builder


    【解决方案1】:

    创建一个类来获取CGRect:

    .h 文件

    @interface FullScreen : UIScreen
    + (CGRect)iOS7StyleScreenBounds;
    @end
    

    .m 文件

    #import "FullScreen.h"
    
    @implementation FullScreen
    + (CGRect)iOS7StyleScreenBounds {
    UIScreen *screen = [UIScreen mainScreen]; CGRect screenRect;
    if (![screen respondsToSelector:@selector(fixedCoordinateSpace)] && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
        screenRect = CGRectMake(screen.bounds.origin.x, screen.bounds.origin.y, screen.bounds.size.height, screen.bounds.size.width);
    } else {
        screenRect = screen.bounds;
    }
    return screenRect;
    }
    @end
    

    并像这样调用这个类: [全屏 iOS7StyleScreenBounds];在你的 .m 文件中

    【讨论】:

    • 我不确定这有什么帮助。我试图避免在代码中设置约束。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-11
    • 1970-01-01
    相关资源
    最近更新 更多