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

  • Question

  • User299153 posted

    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}.

    Friday, April 28, 2017 8:24 AM

All replies

  • User299153 posted

    And It's same result on xamarin studio

    Friday, April 28, 2017 8:26 AM
  • User125801 posted

    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/applicationfundamentals/workingwith_images/launch-screens/#storyboard

    Friday, April 28, 2017 9:12 AM
  • User299153 posted

    @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/applicationfundamentals/workingwith_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.

    Friday, April 28, 2017 1:03 PM