iPad Pro Build Settings display.contentWidth

Hey,

I’m trying to create a full width webview for the iPad pro.

This is my config.lua:

application = { content = { width = display.contentWidth, height = display.contentHeight, fps = 60, imageSuffix = { ["@2x"] = 1.3, }, }, } 

And here’s my test-main.lua

local myText = display.newText( display.contentWidth/2, 100, 200, native.systemFont, 16 ) myText:setFillColor( 1, 0, 0 ) 

In the corona simulator it says the correct contenWidth of 1366. When I view it in the iOS Simulator it says 1024 though. How come?

I just tried the exact same thing with display.pixelWidth but that doesn’t help neither.

Any Ideas?

Thanks so much in advance!

I notice you’ve omitted the “scale” setting, which is not recommended. Please choose one that is suitable to your UI… I suggest “letterbox” or “zoomEven” personally. Are you aware of the differences in the scale options?

Brent

Thank you very much for your reply. I omitted the scale option at some point. I tried setting it to all scale options but it always shows the normal iPads screen width not the iPad pros. I really don’t know what to do.

Really no matter what I do, iPad Air and iPad Pro always have the same screen size. I never receive the actual screen size of the iPad Pro. Is this a Corona Bug?

I guess I could do something like this and then set the width and height manually?

if (system.getInfo("architectureInfo") == "iPad6,8") then //iPad Pro else //normal iPad end

Your config.lua won’t work.

display.contentWidth and display.contentHeight won’t exist until you set width and height in config.lua.

You also do not need to make width and height match the exact device specifications. You can make the width 320 and height 480 and Corona will scale things for you.

The question you have to ask yourself is do you want the top left to be 0, 0, and have a contentWidth and contentHeight that varies from device to device or can you better imagine a fixed box in the center of your screen and you may have visible areas outside that fixed box.

Either do this:

application = {     content =       {         width = 320,         height = 480,         scale = "letterbox",         fps = 60,         imageSuffix =          {             ["@2x"] = 1.5,             ["@4x"] = 3.0,         },     }, }

or

local aspectRatio = display.pixelHeight / display.pixelWidth application = { &nbsp;&nbsp; content = { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width = aspectRatio \> 1.5 and 320 or math.ceil( 480 / aspectRatio ), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height = aspectRatio \< 1.5 and 480 or math.ceil( 320 \* aspectRatio ), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scale = "letterbox", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fps = 60, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imageSuffix = { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ["@2x"] = 1.5, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp; }, }

display.pixelHeight and .pixelWidth are known values during the processing of config.lua but display.contentWidth and display.contentHeight are defined after the config.lua is processed and we know what you want your content area to be.

Rob

Rob, thanks so much again for your reply.

I actually don’t want any scaling to happen. I just want a actual 1024 x 768 webview on iPad and an actual 1366 x 1024 webview on the iPad Pro.

display.pixelWidth in my main.lua gives me the correct screen width of every device (iPhones and iPads) except on the iPad Pro. Instead of giving me 2048 on the Pro it always returns 1536 which is the pixelWidth of the normal iPad. How come? 

It gives me the correct size in the Corona Simulator, but not on the actual device : (

I notice you’ve omitted the “scale” setting, which is not recommended. Please choose one that is suitable to your UI… I suggest “letterbox” or “zoomEven” personally. Are you aware of the differences in the scale options?

Brent

Thank you very much for your reply. I omitted the scale option at some point. I tried setting it to all scale options but it always shows the normal iPads screen width not the iPad pros. I really don’t know what to do.

Really no matter what I do, iPad Air and iPad Pro always have the same screen size. I never receive the actual screen size of the iPad Pro. Is this a Corona Bug?

I guess I could do something like this and then set the width and height manually?

if (system.getInfo("architectureInfo") == "iPad6,8") then //iPad Pro else //normal iPad end

Your config.lua won’t work.

display.contentWidth and display.contentHeight won’t exist until you set width and height in config.lua.

You also do not need to make width and height match the exact device specifications. You can make the width 320 and height 480 and Corona will scale things for you.

The question you have to ask yourself is do you want the top left to be 0, 0, and have a contentWidth and contentHeight that varies from device to device or can you better imagine a fixed box in the center of your screen and you may have visible areas outside that fixed box.

Either do this:

application = { &nbsp;&nbsp; &nbsp;content = &nbsp; &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;width = 320, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;height = 480, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;scale = "letterbox", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;fps = 60, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;imageSuffix = &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;["@2x"] = 1.5, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;["@4x"] = 3.0, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;}, }

or

local aspectRatio = display.pixelHeight / display.pixelWidth application = { &nbsp;&nbsp; content = { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; width = aspectRatio \> 1.5 and 320 or math.ceil( 480 / aspectRatio ), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; height = aspectRatio \< 1.5 and 480 or math.ceil( 320 \* aspectRatio ), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scale = "letterbox", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fps = 60, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imageSuffix = { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ["@2x"] = 1.5, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp; }, }

display.pixelHeight and .pixelWidth are known values during the processing of config.lua but display.contentWidth and display.contentHeight are defined after the config.lua is processed and we know what you want your content area to be.

Rob

Rob, thanks so much again for your reply.

I actually don’t want any scaling to happen. I just want a actual 1024 x 768 webview on iPad and an actual 1366 x 1024 webview on the iPad Pro.

display.pixelWidth in my main.lua gives me the correct screen width of every device (iPhones and iPads) except on the iPad Pro. Instead of giving me 2048 on the Pro it always returns 1536 which is the pixelWidth of the normal iPad. How come? 

It gives me the correct size in the Corona Simulator, but not on the actual device : (