iOS 6 - Distinguishing between iPhone 5 and other devices?

给你一囗甜甜゛ 提交于 2019-11-30 09:51:37

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.

Hashim MH
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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!