Duck
Duck

Reputation: 35933

iphone 4 Simulator reporting 480x320 as the screen size?

I am debugging an application using iPhone 4 Simulator. I have selected it from the simulator menu (device = iPhone 4). When I run the app, the screen size is reported as 480x320 !!??

Is there something I have to modify on this app of mine (originally built for 3G/3gs) in order to make it run on iPhone 4 (yes, I have recreated all artwork as 960x640 and the artwork is on the bundle, but it is scaling it down to half the size... because it is running on 3G/3GS mode, instead of hi res).

running

CGRect cgRect =[[UIScreen mainScreen] bounds];

will result in (0,0,480,320).

Any clues?

thanks for any help.

Upvotes: 0

Views: 4686

Answers (3)

Engin
Engin

Reputation: 89

instead of bounds use currentMode

CGSize pixelBufferSize = [[[UIScreen mainScreen] currentMode] size];

you will get actual resolution

Upvotes: 1

ohho
ohho

Reputation: 51911

Recommended read: http://developer.apple.com/iphone/library/documentation/iphone/conceptual/iphoneosprogrammingguide/SupportingResolutionIndependence/SupportingResolutionIndependence.html

One point does not necessarily correspond to one pixel on the screen.

A sample project, download here.

Upvotes: 3

Jasarien
Jasarien

Reputation: 58448

The iPhone is making the move into resolution independence. This means that things aren't measured in pixels, but in points. Points don't always correspond to pixels.

The screen size of the iPhone 3GS (and previous) is 480x320, in both points an pixels. They correspond on these devices, but in newer devices (like iPhone 4) they do not.

The iPhone 4's screen size is 960x640 in pixels, but its logical screensize is still 480x320 in points.

This allows you to keep your frame, point and size values in their original values and still support larger resolution devices.

On iPhone 4 you need to have @2x somewhere in the name of the image file and it will be used automatically on the higher resolution devices.

When @2x images are loaded, they are loaded as their original resolution, but their size property is halved to be able to work with the logical point measurments.

For instance, an image with an original size of 960x640 will report its size as 480x320 when it's asked for.

Upvotes: 3

Related Questions