Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

ios 11.4 / iPhone X screensize issues on build
Started by tntwickey Aug 30 2018 05:45 AM

7 replies to this topic
iphone x ios 11.4 actualcontentwidth

Best Answer tntwickey , 30 August 2018 - 09:26 AM

It worked Rob. I simply had to update this older game to the new style xcassets = "Images.xcassets", and UILaunchStoryboardName = "LaunchScreen"

 

Thank you!

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

tntwickey

[GLOBAL: userInfoPane.html]
tntwickey
  • Enthusiast

  • 67 posts
  • Corona SDK

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

 

Attached Files



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,838 posts
  • Corona Staff

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


[TOPIC: post.html]
#3

tntwickey

[GLOBAL: userInfoPane.html]
tntwickey
  • Enthusiast

  • 67 posts
  • Corona SDK

 

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}



[TOPIC: post.html]
#4

tntwickey

[GLOBAL: userInfoPane.html]
tntwickey
  • Enthusiast

  • 67 posts
  • Corona SDK

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



[TOPIC: post.html]
#5

tntwickey

[GLOBAL: userInfoPane.html]
tntwickey
  • Enthusiast

  • 67 posts
  • Corona SDK

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)

Attached Files



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,838 posts
  • Corona Staff

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



[TOPIC: post.html]
#7

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

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.

 

Attached File  iphonex.png   23.24KB   1 downloads


  • tntwickey likes this

[TOPIC: post.html]
#8

tntwickey

[GLOBAL: userInfoPane.html]
tntwickey
  • Enthusiast

  • 67 posts
  • Corona SDK

  Best Answer

It worked Rob. I simply had to update this older game to the new style xcassets = "Images.xcassets", and UILaunchStoryboardName = "LaunchScreen"

 

Thank you!




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: iphone x, ios 11.4, actualcontentwidth