ios - 如何检测设备是否为 iPhone 5?

标签 ios xcode

<分区>

Possible Duplicate:
How to detect iPhone 5 (widescreen devices)?

我正在尝试向现有 ios4 项目添加新 View 以处理新的 iphone5 屏幕尺寸。

但是我这里没有可以测试的 iPhone,而且我用来测试屏幕尺寸的代码也不起作用,只是想知道是否有另一种检测设备类型的方法?

NSLog(@"%f", [ [ UIScreen mainScreen ] bounds ].size.height);

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
    if([UIScreen mainScreen].bounds.size.height == 568.0)
    {
        //move to your iphone5 storyboard
        [self changeView:splashScreenBIGV viewH:splashScreenH animLength:SCREEN_CHANGE_ANIM_LENGTH];
   }
    else{
        //move to your iphone4s storyboard
        [self changeView:splashScreenV viewH:splashScreenH animLength:SCREEN_CHANGE_ANIM_LENGTH];            
    }
}

最佳答案

对于我的通用应用程序,Forex App ,我只是像这样使用屏幕高度检测概念:

CGSize screenSize = [[UIScreen mainScreen] bounds].size;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    if (screenSize.height > 480.0f) {
        /*Do iPhone 5 stuff here.*/
    } else {
        /*Do iPhone Classic stuff here.*/
    }
} else {
    /*Do iPad stuff here.*/
}

关于ios - 如何检测设备是否为 iPhone 5?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12604944/

相关文章:

iphone - 从照片库中选择多张图片

objective-c - 在 IB 中,如何将现有组件放置在新的 SplitView 中?

ios - 如何移动 UIView 并使用 Swift 以编程方式放置新的 UIView?

ios - UISearchController 保留问题

iphone - 使用 SecKeyWrapper 中断加密 16 个字节的 UTF8 (ccStatus == -4304)

ios - 找不到实例方法 '-_setWebGLEnabled:' (返回类型默认为 'id' )

ios - 回到屏幕时,导致我的应用崩溃的原因是什么?

ios - XCTest:在没有完成 block 的情况下测试异步函数

ios - 使一键更改标签文本以在模式之间切换

iphone - 屏幕解锁时 Apple 推送通知不会到达