0

I have built an application using Xcode 6 for iOS 8.

I have also installed the additional iOS 7.1 simulator to allow me to test for previous operating systems.

The issue I'm having is, when I run the application on an iOS 7.1 iPhone 5 or 5s, it appears to think the phone is an iPhone 4s.

I have implemented the following code to allow me to identify the issue.

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

The log output is:

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

I really don't understand what the issue is, but it's preventing my application from working on iOS 7 iPhone 5 and 5s. It does not affect other iOS devices such as an iPad Air running iOS 7, however when I simulate an iPhone 4s with iOS 7 some of my elements from one particular view controller do not appear.

B-B.
  • 193
  • 1
  • 3
  • 14
  • 2
    WOW just wow, why would you write code like this. Just use [`[UIDevice systemName]`](https://developer.apple.com/library/iOS/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/occ/instp/UIDevice/localizedModel) it is better to detect the device type – rckoenes Oct 10 '14 at 12:33
  • 2
    Very constructive. Even so, the question wasn't about the code. It was about Xcode. As stated, it seems to think my device is an iPhone 4/4s when its not. – B-B. Oct 10 '14 at 12:38
  • 1
    First of, Xcode is just an IDE. The iOS SDK is where your issue is really at. You code although working is not correct, since it is very easy incorrectly detect device. Like what will happen if you run the app in a iPad. Of an iPad Touch? My main question would be, why do you need to detect the device type at all. And sorry for not being constructive. – rckoenes Oct 10 '14 at 12:41
  • 2
    do you have a suitable LaunchImage? Only then does iOS treat it is a 5 app – Daij-Djan Oct 10 '14 at 12:43
  • Thank you Dahi-Djan, I didn't realise an applicable LaunchImage was necessary! This has rectified this issue. – B-B. Oct 10 '14 at 12:48
  • @StefanB. I agree with `rckoenes` comments it seems that you are trying to reinvent the wheel and you keep coming out with a square. Also as a side note if you post code on here whether in a question or in an answer it will more than likely get some sort of code review from other users, it's not a bad thing I myself have learned a lot from these people. I would recommend just taking the advice however bad it might seem. – Popeye Oct 10 '14 at 13:21
  • There's not really enough context in your code snippet to help. In any event, use UIDevice. – Jeremy Huddleston Sequoia Oct 11 '14 at 03:50

0 Answers0