-->

的iOS 6 - iPhone 5和其他设备之间的区别?(iOS 6 - Distinguish

2019-06-28 07:11发布

随着iPhone 5的发布和新的iPod今天,我在优化我的应用程序采取新的,额外的屏幕空间的优势开始工作。 我已经有到我的应用程序是不是“信箱”了点。 我知道它的早期,但没有人知道我怎么可以在新的,更高的设备和旧的区别?

理想的情况下,这将是这样的:

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
}

谢谢! 我希望其他人也享受苹果公司今天宣布,以及!

Answer 1:

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



Answer 2:

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

看到此链接为不同的类型检查



Answer 3:

- (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));
}


Answer 4:

对于那些屏幕仍然会返回480而不是568,你需要在应用程序设置摘要选项卡中的新的大小添加新的启动映像。



文章来源: iOS 6 - Distinguishing between iPhone 5 and other devices?