Xcode模拟器将我的iPhone 5s视为iPhone 4s

时间:2014-10-10 12:26:23

标签: objective-c xcode ios7 ios8 ios7.1

我已经使用Xcode 6为iOS 8构建了一个应用程序。

我还安装了额外的iOS 7.1模拟器,以便我测试以前的操作系统。

我遇到的问题是,当我在iOS 7.1 iPhone 5或5s上运行应用程序时,似乎认为手机是iPhone 4s。

我已经实现了以下代码,以便我确定问题。

if (width == 320 && height == 480) {
        device = @"iPhone4";
    } else if (width == 320 && height == 568) {
        device = @"iPhone5";
    } else if (width == 375 && height == 667) {
        device = @"iPhone6";
    } else if (width == 414 && height == 736) {
        device = @"iPhone6plus";
    } else if (width == 768 && height == 1024) {
        device = @"iPad";
    }

if ([device isEqual: @"iPhone4"]) {
        NSLog(@"This is an iPhone 4 or 4s");
    } else if ([device isEqual: @"iPhone5"]) {
        NSLog(@"This is an iPhone 5, 5c or 5s");
    } else if ([device isEqual: @"iPhone6"]) {
        NSLog(@"This is an iPhone 6");
    } else if ([device isEqual: @"iPhone6plus"]) {
        NSLog(@"This is an iPhone 6 Plus");
    } else if ([device isEqual: @"iPad"]) {
        NSLog(@"This is an iPad, iPad 2 or iPad Air");
    }

日志输出为:

2014-10-10 13:22:04.558 GE Careers UK[4110:60b] This is an iPhone 4 or 4s

我真的不明白这是什么问题,但它阻止我的应用程序在iOS 7 iPhone 5和5s上工作。它影响其他iOS设备,例如运行iOS 7的iPad Air,但是当我使用iOS 7模拟iPhone 4s时,我的某些特定视图控制器中的某些元素不会出现。

0 个答案:

没有答案