Question

I want to get the width and height of the screen, with this code ...

float screenWidth = [UIScreen mainScreen].bounds.size.width;
float screenHeight = [UIScreen mainScreen].bounds.size.height;
NSLog(@"%f %f",screenWidth, screenHeight);

I get always 320 480 , but these aren't the true measures of the simulator. Now I'm testing on a retina simulator with more resolution, but i always get 320 480

Était-ce utile?

La solution

I think your answer can be found here: in iPhone App How to detect the screen resolution of the device

Its the scale that interests you as well. Use CGFloat screenScale = [[UIScreen mainScreen] scale]; to find out the scale.

When positioning elements your points should always be in non-retina scale. Size of the screen for 3.5 inch is 320x480 units and 320x568 for the 4 inch screen. The pixel resolution is times two for retina screens.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top