Real iPhone XR screen resolution differs from screen resolution given by swift

0 votes
Screenshots, the Apple website, and other sources all indicate the following for the iPhone XR:

828x1792

Swift estimates the iPhone XR's screen resolution to be:

375x812 (or 750x1624)

Why is that and how do I handle it?

NOTE: All iPhones up to and including the iPhone XR (plus the iPhone XR simulator) function correctly.
Sep 28, 2022 in IOS by Soham
• 9,710 points
803 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Native resolution and UIKit size are two distinct ideas.

When arranging views inside your project, UIKit size is represented as points. Your view will be in the centre of the screen if your screen is 414x896 points in size and you centre it at [207,448].

The number of pixels on the screen of the device is indicated by the native resolution, which is denoted by pixels. By multiplying the UIKit size by the Native Scale factor, which varies for each device, you may obtain the native resolution of the device.

All iPhones that support iOS 12 have the following sizes, scale factors, and resolutions shown in a table.

iPhone       | UIKit size (points) | Native resolution (pixels) | Native Scale factor
-------------|---------------------|----------------------------|--------------------
Xs Max       | 414x896             | 1242x2688                  | 3
X, Xs        | 375x812             | 1125x2436                  | 3
Xr           | 414x896             | 828x1792                   | 2
6+,6s+,7+,8+ | 414x736             | 1080x1920                  | 2.608
6,6s,7,8     | 375x667             | 750x1334                   | 2
5s,SE        | 320x568             | 640x1136                   | 2

... from this table you can see that your iPhone Xr has UIKit size 414x896, not 375x812 as your wrote in your question.

You can get device's UIKit size by getting screen's bounds

UIScreen.main.bounds

and native resolution by getting native bounds

UIScreen.main.nativeBounds

Check once more to make sure your code is running on iPhone Xr and not iPhone Xs/X, which has a UIKit size of 375x812. Each of them works fine for iPhone Xr. Additionally, the 750x1624 resolution is simply a strange scale of Xr's native resolution, so make sure you aren't doing any additional arithmetic.

answered Sep 28, 2022 by Rahul
• 9,680 points

edited Mar 5

Related Questions In IOS

0 votes
1 answer

what font face of clock on lock screen of iPhone (iOS 9)?

San Francisco is the default font in ...READ MORE

answered Sep 20, 2022 in IOS by Aditya
• 7,680 points
1,429 views
0 votes
1 answer

Detecting iPhone 6/6+ screen sizes in point values

The device screen will be the first ...READ MORE

answered Sep 22, 2022 in IOS by Rahul
• 9,680 points
1,051 views
0 votes
0 answers

How I can open native alarm clock in iphone by using code?

I need to create a sample app ...READ MORE

Sep 22, 2022 in IOS by Soham
• 9,710 points
443 views
0 votes
0 answers

Angle to Mecca from current location with iPhone compass

I am developing an iPhone application that ...READ MORE

Sep 27, 2022 in IOS by Soham
• 9,710 points
426 views
0 votes
0 answers

Launch an app from within another (iPhone)

Is it possible to open any iPhone ...READ MORE

Sep 28, 2022 in IOS by Soham
• 9,710 points
537 views
0 votes
1 answer

Call the official *Settings* app from my app on iPhone

It also functions in iOS versions greater ...READ MORE

answered Nov 4, 2022 in IOS by Rahul
• 9,680 points
891 views
0 votes
1 answer

Get User Group in Swift using AWS Cognito

The groups are exposed in the ID ...READ MORE

answered Nov 12, 2018 in AWS by Priyaj
• 58,020 points
1,640 views
0 votes
1 answer

URL Scheme for iOS Home App

I think you could try doing it ...READ MORE

answered Nov 16, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,243 views
0 votes
1 answer

iOS App : Porting Code to App

If you make a post, missing parameters ...READ MORE

answered Jan 18, 2019 in IoT (Internet of Things) by Shubham
• 13,490 points
843 views
0 votes
1 answer

swift for windows? xcode on windows? ?

Hi, @Aminegac, If you’re a little more technically ...READ MORE

answered Dec 4, 2020 in Others by Nikita
1,938 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP