Josh Wang
Josh Wang

Reputation: 305

How to fix my [UIScreen mainscreen] recognizing iPhone 5 as iPhone 4

I have an iPhone 5 and an iPhone 4s that I am testing an xcode project on. I deleted my app on the iPhone 5 and re-built it and now it recognizes the iphone 5 as an iphone 4. I have tried both

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    NSLog(@"screen size is %f", screenSize.height);
    if (screenSize.height > 480.0f) {
        return TRUE;
    } else {
        return FALSE;
    }
}

and

#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPhone" ] )
#define IS_IPOD   ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPod touch" ] )
#define IS_IPHONE_5 ( IS_IPHONE && IS_WIDESCREEN )

The problem is that somehow [UIScreen mainScreen]bounds.size.height is recognizing my screen height as 480.00000 not 586. Has anyone encountered this error and how do i fix it?

Upvotes: 0

Views: 459

Answers (1)

Josh Wang
Josh Wang

Reputation: 305

You must have a [email protected] image in your code for it to recognize the proper screen height otherwise it will always be FALSE. I had accidentally deleted this image in between builds so it never tested properly.

Upvotes: 2

Related Questions