iOS 6 - Distinguishing between iPhone 5 and other

2019-02-07 05:05发布

With the announcement of the iPhone 5 and new iPods today, I'm starting work on optimizing my app to take advantage of the new, extra screen space. I've already got to the point where my app isn't "letterboxed" anymore. I know it's early, but does anyone know how I could distinguish between the new, taller devices and the old ones?

Ideally, it would be something like this:

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
}

Thanks! I hope everyone else is also enjoying what Apple announced today as well!

4条回答
我想做一个坏孩纸
2楼-- · 2019-02-07 05:08
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        // iPhone Classic
    }
    if(result.height == 568)
    {
        // iPhone 5
    }
}

see this link for different type of checking

查看更多
不美不萌又怎样
3楼-- · 2019-02-07 05:15

On the top of my head, you can use bounds information for the UIScreen [UIScreen mainScreen].bounds and check the height or better the ratio of the screen.

查看更多
唯我独甜
4楼-- · 2019-02-07 05:18
- (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));
}
查看更多
放荡不羁爱自由
5楼-- · 2019-02-07 05:23

For those that the screen still returns 480 instead of 568, you need to add a new launch images with the new size in the summary tab of application settings.

查看更多
登录 后发表回答