Return value [UIScreen mainScreen] .bounds.size.height on iphone 6

I run my code on the iphone 6 device in portrait mode.

NSLog(@"main screen height : %f", [UIScreen mainScreen].bounds.size.height); 

Why does it return 568.0 and not 667.0?

IPhone mode is standard - it does not scale.

EDIT: This happens even on the simulator - when I select a device for iphone 6.

+5
source share
4 answers

Add a pop-up image for iPhone 6, then it will work the way you want

Click on images.xcassets, click on the attribute inspector and select iOS 8.0 and later.

choose iOS 8.0 and Later

then you will get the option for two additional launch images as shown below Drag the retina size image for iPhone 6 and iPhone 6 plus in Retina HD 4.7 and Retina HD 5.5 respectively

Add launch image for Retina HD

+9
source

Running images is out of date. Add one resizable launch screen size and you will always get your own resolution in iOS 8 (this is the oldest operating system in which the iPhone 6 will work).

Go to File> New> File> iOS User Interface> Launch Screen.

Make a storyboard launch screen. This will work for any screen size, present or future.

Click the "General" tab for the target purpose of your application. In the "Application Icons and Launch Images" section, select the launcher file you just created.

+1
source

Launching images is still necessary if you need to continue to support iOS 7, otherwise you can change the size of the launch screen (storyboard).

0
source

Janmenjay's answer is right, but not complete in some cases. After what Janmenjaya suggests, go to TARGETS-> General-> App Icons and Launch Images-> Launch Images Source, then select the name of the startup image. Next time run the project, the height will be correct.

0
source

Source: https://habr.com/ru/post/1209010/


All Articles