ios 11.4 / iPhone X screensize issues on build

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"})

config.lua

application = { content = { width = 640,--960, height = 960,--640, scale = "letterbox", fps=30, imageSuffix = { ["@2x"] = 2, --["@3x"] = 4, } }, }

What does this do:

-- Create a vector rectangle sized exactly to the screen area local screenArea = display.newRect( display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight ) --local actualWidth = math.floor((display.actualContentWidth/display.contentScaleX)+0.5) --local actualHeight = math.floor((display.actualContentHeight/display.contentScaleY)+0.5) local acutalWidth = display.actualContentWidth local actualHeight = display.actualContentHeight 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 

actualWidth/actualHeight: {640, 1385.8133544922}

and iPhone Sim

actualWidth/actualHeight: {640, 960}

I downloaded and installed this template https://coronalabs.com/blog/2017/01/19/endless-sk8boarder-the-latest-template-from-ponywolf/ without any edits whatsoever to my iPhone X. The exact same results. The game only fills 2/3 of the screen

A screenshot from my device. All that black space is simply empty. The game occupies the middle 2/3 of the screen. Exactly like my white square.

I am running iOS 11.4.1 and Xcode 9.4.1 and

Corona Version 2018.3326 (2018.6.25)

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:

 -- -- iOS section -- iphone = { xcassets = "Images.xcassets", plist = { UIStatusBarHidden = false, UILaunchStoryboardName = "LaunchScreen", }, },

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.

Rob

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 worked Rob. I simply had to update this older game to the new style xcassets = “Images.xcassets”, and UILaunchStoryboardName = “LaunchScreen”

Thank you!

What does this do:

-- Create a vector rectangle sized exactly to the screen area local screenArea = display.newRect( display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight ) --local actualWidth = math.floor((display.actualContentWidth/display.contentScaleX)+0.5) --local actualHeight = math.floor((display.actualContentHeight/display.contentScaleY)+0.5) local acutalWidth = display.actualContentWidth local actualHeight = display.actualContentHeight 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 

actualWidth/actualHeight: {640, 1385.8133544922}

and iPhone Sim

actualWidth/actualHeight: {640, 960}

I downloaded and installed this template https://coronalabs.com/blog/2017/01/19/endless-sk8boarder-the-latest-template-from-ponywolf/ without any edits whatsoever to my iPhone X. The exact same results. The game only fills 2/3 of the screen

A screenshot from my device. All that black space is simply empty. The game occupies the middle 2/3 of the screen. Exactly like my white square.

I am running iOS 11.4.1 and Xcode 9.4.1 and

Corona Version 2018.3326 (2018.6.25)

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:

 -- -- iOS section -- iphone = { xcassets = "Images.xcassets", plist = { UIStatusBarHidden = false, UILaunchStoryboardName = "LaunchScreen", }, },

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.

Rob

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 worked Rob. I simply had to update this older game to the new style xcassets = “Images.xcassets”, and UILaunchStoryboardName = “LaunchScreen”

Thank you!