iOS 6 - 区分iPhone 5和其他设备?

mhb*_*bdr 6 iphone xcode objective-c ios6 iphone-5

随着今天iPhone 5和新iPod的发布,我开始优化我的应用程序,以利用新的额外屏幕空间.我已经到了我的应用程序不再是"letterboxed"的地步了.我知道这是早期的,但有谁知道如何区分新的,更高的设备和旧设备?

理想情况下,它会是这样的:

if (device is iPhone 5 or taller iPod touch) {
    do stuff that is ideal for the taller screen
} else {
   do what I've been doing before for the smaller screen
}
Run Code Online (Sandbox Code Playgroud)

谢谢!我希望其他人也能享受Apple今天宣布的内容!

Has*_* MH 14

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        // iPhone Classic
    }
    if(result.height == 568)
    {
        // iPhone 5
    }
}
Run Code Online (Sandbox Code Playgroud)

请参阅此链接以了解不同类型的检查


Mar*_*rco 12

- (BOOL)isTall
{
    CGRect bounds = [[UIScreen mainScreen] bounds];
    CGFloat height = bounds.size.height;
    CGFloat scale = [[UIScreen mainScreen] scale];

    return (([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) && ((height * scale) >= 1136));
}
Run Code Online (Sandbox Code Playgroud)


ove*_*ing 6

在我的头顶,你可以使用UIScreen的边界信息, [UIScreen mainScreen].bounds并检查高度或更好的屏幕比例.