Different display.screenOriginY values on simulator and device (iPhone6)

I’m making a portrait app for iPhone6. 

On the Corona Simulator, iPhone6 skin:

display.screenOriginY == -44.5 

On the Xcode simulator, iPhone6 skin:

display.screenOriginY == -44 

But on an actual iPhone6

display.screenOriginY == -33.5 

Why are they different? And why is the actual iPhone6 value SO different?

Thanks in advance,

Mat

I could explain it on a 6 plus, not a standard 6.  Can you print out some of the additional values around what it things the screen’s screen is?

Rob

Rob

Please see values below:

CORONA SIMULATOR

display.contentScaleX = 0.42666667699814 display.contentScaleY = 0.42666667699814 display.screenOriginX = -0 display.screenOriginY = -44.5 display.actualContentWidth = 320 display.actualContentHeight = 569.17333984375 display.pixelWidth = 750 display.pixelHeight = 1334 display.contentWidth = 320 display.contentHeight = 480 display.contentCenterX = 160 display.contentCenterY = 240 display.viewableContentWidth = 320 display.viewableContentHeight = 480

iPHONE6 DEVICE

display.contentScaleX = 0.42666667699814 display.contentScaleY = 0.42666667699814 display.screenOriginX = -0 display.screenOriginY = -33.5 display.actualContentWidth = 320 display.actualContentHeight = 547.84002685547 display.pixelWidth = 750 display.pixelHeight = 1331 display.contentWidth = 320 display.contentHeight = 480 display.contentCenterX = 160 display.contentCenterY = 240 display.viewableContentWidth = 320 display.viewableContentHeight = 480

config.lua: 

content = { width = 320, height = 480,  scale = "letterbox" }

Why can you explain on an iPhone 6 Plus? I only use Corona Simulator/Xcode simulator to test on that device, and I’ve always assumed that layout would be identical from simulator(s) to device. Now I have doubts!

Thanks

Mat

Well the 6 plus is a special beast.  It’s a 1080 x 1920 screen for games, videos and such, but its  a bit bigger for Apple UI based apps.  Corona SDK returns the values for 1080 x 1920.  The Xcode simulator assumes it’s a UI app and returns 1242 x 2208.  It reports right on the device because we are an OpenGL full screen app.

But in your case, the problem is a little different.  Your phone is running in iPhone 5 compatibility mode.   See:

https://coronalabs.com/blog/2014/10/07/tutorial-working-with-the-new-iphones/

https://coronalabs.com/blog/2014/10/21/tutorial-building-multi-screen-launch-images-using-xcode-6/

https://docs.coronalabs.com/guide/distribution/buildSettings/index.html#launchimage

Rob

Rob

Thanks for your help. I was changing the values of display.contentWidth and display.contentHeight (albeit after I printed the values above to console), and that was messing up the display. 

I have now removed the offending lines, and the device is outputting sensible numbers again (very close to simulator, through not quite the same eg. 750 x 1331 on device).

Thanks also for reminding me to add the LaunchScreen.nib to get iPhone6 mode working. I’d done this with another app, just forgot with this app.

For other readers, this involves:

  1. Creating a LaunchScreen.xib in Xcode interface builder

2. Copying the output LaunchScreen.nib into your project root

  1. Copying the png that you used in interface builder to your project root, and

  2. In build.settings, add this to iphone.plist:

                UILaunchStoryboardName = “LaunchScreen”

Then you will get ‘optimised for iPhone6 and 6Plus’ in your store listing. 

Mat

I could explain it on a 6 plus, not a standard 6.  Can you print out some of the additional values around what it things the screen’s screen is?

Rob

Rob

Please see values below:

CORONA SIMULATOR

display.contentScaleX = 0.42666667699814 display.contentScaleY = 0.42666667699814 display.screenOriginX = -0 display.screenOriginY = -44.5 display.actualContentWidth = 320 display.actualContentHeight = 569.17333984375 display.pixelWidth = 750 display.pixelHeight = 1334 display.contentWidth = 320 display.contentHeight = 480 display.contentCenterX = 160 display.contentCenterY = 240 display.viewableContentWidth = 320 display.viewableContentHeight = 480

iPHONE6 DEVICE

display.contentScaleX = 0.42666667699814 display.contentScaleY = 0.42666667699814 display.screenOriginX = -0 display.screenOriginY = -33.5 display.actualContentWidth = 320 display.actualContentHeight = 547.84002685547 display.pixelWidth = 750 display.pixelHeight = 1331 display.contentWidth = 320 display.contentHeight = 480 display.contentCenterX = 160 display.contentCenterY = 240 display.viewableContentWidth = 320 display.viewableContentHeight = 480

config.lua: 

content = { width = 320, height = 480,  scale = "letterbox" }

Why can you explain on an iPhone 6 Plus? I only use Corona Simulator/Xcode simulator to test on that device, and I’ve always assumed that layout would be identical from simulator(s) to device. Now I have doubts!

Thanks

Mat

Well the 6 plus is a special beast.  It’s a 1080 x 1920 screen for games, videos and such, but its  a bit bigger for Apple UI based apps.  Corona SDK returns the values for 1080 x 1920.  The Xcode simulator assumes it’s a UI app and returns 1242 x 2208.  It reports right on the device because we are an OpenGL full screen app.

But in your case, the problem is a little different.  Your phone is running in iPhone 5 compatibility mode.   See:

https://coronalabs.com/blog/2014/10/07/tutorial-working-with-the-new-iphones/

https://coronalabs.com/blog/2014/10/21/tutorial-building-multi-screen-launch-images-using-xcode-6/

https://docs.coronalabs.com/guide/distribution/buildSettings/index.html#launchimage

Rob

Rob

Thanks for your help. I was changing the values of display.contentWidth and display.contentHeight (albeit after I printed the values above to console), and that was messing up the display. 

I have now removed the offending lines, and the device is outputting sensible numbers again (very close to simulator, through not quite the same eg. 750 x 1331 on device).

Thanks also for reminding me to add the LaunchScreen.nib to get iPhone6 mode working. I’d done this with another app, just forgot with this app.

For other readers, this involves:

  1. Creating a LaunchScreen.xib in Xcode interface builder

2. Copying the output LaunchScreen.nib into your project root

  1. Copying the png that you used in interface builder to your project root, and

  2. In build.settings, add this to iphone.plist:

                UILaunchStoryboardName = “LaunchScreen”

Then you will get ‘optimised for iPhone6 and 6Plus’ in your store listing. 

Mat