iPhone XR and XS Max wrong nativeBounds in Xcode 10 GM Simulator?

Perhaps I'm doing this wrong, but this line of code:


[UIScreen mainScreen].nativeBounds.size


Returns 1125 x 2436 from iPhone XS Max simulator instead of the expected 1242 x 2688.

Returns 750 x 1624 from iPhone XS Max simulator instead of the expected 828 x 1792.


Any ideas why this would be?

Replies

I meant that iPhone XR returns 750 x 1624 instead of the expected 828 x 1792.

I found the answer. The Simulator reported these sizes because my app project's base SDK is set to iOS 10 or later, so my app's UI is being scaled by the system. My project's base SDK must be set to iOS 11 or later to enable full screen resolution on the iPhone XS, XS Max, and XR.

Got the same issue. However in my case the baseSDK is just set to iOS. There is no choice of version numbers available (did you have older SDKs installed)? So at the moment a bit stuck as screen size for iPhone XR and XS Max is always same as iPhone X.

The same issue here. I have an old project that its Base SDK is simply iOS, and its iOS Deployment Target is iOS 10.0. Calling UIScreen.main.nativeBounds.size returns the same values as lifjoy described for XR and XS Max. Changing deployment target to 11.0 or 12.0 does not effect the values, though.


BTW, I happened to create a new empty project with Xcode 9; when using Xcode 10 GM to open and run the project, both XR and XS Max simulators return the true native values listed in the Human Interface Guidelines.

Does your project have a launch xib or storyboard and is it selected as the Launch Screen File in the General section of your project?

No, I don't use Launch Screen File for this project; I simply use a launch image.

It is connected with the launch image resolution. Try to add the launch image with right resolution for iPhone XR and XS Max in Images.xcassets.