Using display.actualContentWidth and display.actualContentHeight does not work on iPhone X 11.4 to get the screen size. It works perfectly in the corona simulator, however, on an actual iPhone X and the Xcode iPhone X simulator it shows a wrong size. See the screenshots.
Any ideas?
main.lua
-- Create a vector rectangle sized exactly to the screen area local screenArea = display.newRect( display.screenOriginX, display.screenOriginY, display.actualContentWidth, display.actualContentHeight ) screenArea:translate( screenArea.width\*0.5, screenArea.height\*0.5 ) local actualWidth = math.floor((display.actualContentWidth/display.contentScaleX)+0.5) local actualHeight = math.floor((display.actualContentHeight/display.contentScaleY)+0.5) local \_msg = 'actualWidth/actualHeight: {' .. actualHeight .. ', ' .. actualWidth .. '}' native.showAlert( "Attention!", \_msg, {"Ok"})
It just creates a white box the size of the screen. The msg prints out with an alert box showing what it believes the actual size of the screen is. It is wrong, and the white box does not fill the screen.
Printing out display.actualContentWidth and Height in the Corona simulator yields
The problem is you don’t have a complete Corona project. You didn’t post your build.settings and I’m pretty sure you don’t have launch images and icons configured. On device, Apple looks for launch images to determine if you’re on an iPhone 5 or later (i.e. Tall Mode) and then the iPhone 6/7/8, 6+,/7+/8+ also uses launch images to determine size parameters.
If you start with a new Corona project (Welcome screen, new Project and let it create all the files, you will have a folder with an Images.xassets folder and a LaunchScreen.storyboardc file. Your build.settings will contain these lines:
Once you have this in your project, you will get the proper values when running on any iPhone 5 or later model. These are required files to submit to the iOS App Store, so it’s important to include this in your builds for devices.
I don’t have a portrait app but I can confirm that it works as expected on two of my apps currently on the store. These are the screenshots at the top of my app running in the simulator.
It just creates a white box the size of the screen. The msg prints out with an alert box showing what it believes the actual size of the screen is. It is wrong, and the white box does not fill the screen.
Printing out display.actualContentWidth and Height in the Corona simulator yields
The problem is you don’t have a complete Corona project. You didn’t post your build.settings and I’m pretty sure you don’t have launch images and icons configured. On device, Apple looks for launch images to determine if you’re on an iPhone 5 or later (i.e. Tall Mode) and then the iPhone 6/7/8, 6+,/7+/8+ also uses launch images to determine size parameters.
If you start with a new Corona project (Welcome screen, new Project and let it create all the files, you will have a folder with an Images.xassets folder and a LaunchScreen.storyboardc file. Your build.settings will contain these lines:
Once you have this in your project, you will get the proper values when running on any iPhone 5 or later model. These are required files to submit to the iOS App Store, so it’s important to include this in your builds for devices.
I don’t have a portrait app but I can confirm that it works as expected on two of my apps currently on the store. These are the screenshots at the top of my app running in the simulator.