Curnelious
Curnelious

Reputation: 1

iPhone6 screen size returns 375 on simulator

My project has launch images for all iPhones iOS7,iOS8.

Anyway it keeps returning wrong value for the screen width in simulator:

   NSLog(@"%f",[UIScreen mainScreen].bounds.size.width);
    NSLog(@"%f",self.view.frame.size.width);

both always are 375.0.

What am i missing ?

Upvotes: 1

Views: 292

Answers (1)

Nils Ziehn
Nils Ziehn

Reputation: 4331

The actual screen size of iPhone6 is 750 pixels, but iOS does not return the pixel size in the frame or bounds, but the point size!

If you want to know how many pixels are in a point you have to use [UIScreen mainScreen].scale .

For iPhone6plus this is even more complicated since it also introduces a 'native scale'. Everything is drawn into a larger image and the reduced down to the 1920x1080 screen that the iPhone 6 actually has. For this you would use [UIScreen mainScreen].nativeScale [Careful, native scale is only available on iOS8 and your app will crash if you use it on iOS.]

P.S. If you are not using any splash image (other than -568h@2x), you will get 320x568 for iPhone 6 and 6+.

Upvotes: 4

Related Questions