Forum Xamarin.iOS

Why UIScreen.MainScreen.Bounds didn't have correct value when you debug on real device?

XiaoYipengXiaoYipeng USMember ✭✭


I Creat a new single view app (iphone) project,then add a line code to print UIScreen.MainScreen.Bounds .
I use my iphone6s debug it , it print the UIScreen.MainScreen.Bounds is {X=0,Y=0,Width=320,Height=568}.
The right value is {X=0,Y=0,Width=375,Height=667}.

Posts

  • XiaoYipengXiaoYipeng USMember ✭✭

    And It's same result on xamarin studio

  • BytesGuyBytesGuy GBXamarin Team Xamurai

    320x568 indicates the app is running in the resolution that is compatible with the 4" iPhones - the app should appear to be scaled up on 4.7" and 5.5" screens. When the app is running in this scaled mode, the bounds reported will be that of the 4" resolution.

    To get the native resolution of your 4.7" display, you need to create a launch storyboard: https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/launch-screens/#storyboard

  • XiaoYipengXiaoYipeng USMember ✭✭

    @BytesGuy said:
    320x568 indicates the app is running in the resolution that is compatible with the 4" iPhones - the app should appear to be scaled up on 4.7" and 5.5" screens. When the app is running in this scaled mode, the bounds reported will be that of the 4" resolution.

    To get the native resolution of your 4.7" display, you need to create a launch storyboard: https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/launch-screens/#storyboard

    This is my launch screen:

    And This is screenshot on my iphone6s:

    This is print Bounds, NativeBounds, NativeScale on console:

    The Bounds is incorrect, but the NativeBounds is correct, and the NativeScale is incorrect too.
    But the incorrect Bounds multiply incorrect NativeScale is right the correct NativeBounds.
    So if I use UIScreen.MainScreen.Bounds set key window frame, it is right on screen.
    but it is too strange to me.

Sign In or Register to comment.