display.pixelHeight not returning the correct value in iOS device

display.pixelHeight is not returning the correct value on my iPhone 5 iOS 10.2.1 since I started testing today.

It’s returning 640 for width and 960 for height. That’s the specs of an iPhone 4, it should be 1136 for height.

It is my only device with iOS 10 (10.2.1), other devices I tested with iOS 9 are working fine. Android is also going fine

print(display.pixelWidth, display.pixelHeight) --Will print 640 960 on my iPhone 5

my config file:

application = { content = { width = display.pixelWidth, height = display.pixelHeight, scale = "letterBox", fps = 60, xAlign = "center", yAlign = "top" }, }

Build 2017.3061

Any ideas?

Try adding a png called Default-568h@2x.png to your build.  This forces the proper view.  Although there is talk of this being replaced.  Perhaps Corona can chime in here.

It worked!

Will this affect only the iPhone 5 or I should be worried with the others?

thanks

Just iphone 5 AFAIK

So do I have to put other images for the other screen sizes?

No, just that specific texture and for iPhone 5.

It is because of a legacy feature/rule associated with the switch between iPhone4 resolution/aspect ratio and the new (at the time) iPhone 5 resolution & aspect ratio.

I believe at the time, this was a quick way for users to re-release their apps and tell the OS, “I’ll handle scaling”.  i.e. If a legacy app was opened on iPhone5 when it first came out it would stretch to fit the screen.  My memory may be faulty here, but I think that is what happened.

As you can imagine, when the iPhone 5 came out and all the apps were designed for 320x480 and 640x960 it was a bit of a challenge for developers to update their apps.

Ok then. Thanks for the clarifications

When Apple introduced the iPhone 5, they needed a way to know if apps were written to take advantage of “Tall” mode. They did this by having the developer include a file named Default-568h@2.png. This was all you needed in iOS 6, the OS that came with the iPhone 6. All you needed to do was include the file in your folder with main.lua.

Two years later, we got iOS 8 and two new phones, the iPhone 6 and 6 plus. These were even bigger screens and Apple ran into a problem. Continuing along this adding files would not be sustainable for long. They also needed to include landscape files for the Plus models and there were now multiple iPads out as well. Apple stopped being dependent on just the presence of the 568h file since they now also needed Default-667h@2x.png and Default-733@3x.png files for the new phones to get out of “iPhone 5 compatibility mode”. They introduced a plist table to identify the files and other than the Default-568h@2x.png file which had to be named that, Apple’s new plist method let you have some flexibility on file naming.  iOS 8 also brought us Storyboard based launch image setups, which requires some tinkering inside of Xcode to make it work.

We have supported the “static file” method (and still do) where you put this crazy table in your build.settings and include a bunch of launch images in the root folder. The UILaunchImages show before our splash screen. Apple doesn’t want developers using static files any longer and they really want you to use storyboard based launch image setups.

Now that we’ve dropped support with iOS 6 and 7 in the latest daily builds (and in the upcoming public build), we are now promoting the use of storyboards instead of static images.

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

Which should eventually lead you here: https://docs.coronalabs.com/guide/distribution/launchFile/index.html

At the bottom of that guide is the setup for static images. You will see how crazy that table is.  Storyboard is one line in build.settings. Your app would just need a .storyboardc file exported from Xcode and three image files that match a particular file name (that you determine when setting up the storyboard or use our default) and drop the four files in with main.lua.  This is the major league way to go!

Rob

Interesting to know why this happened. I wasn’t around when the iPhone 5 came.
I remember using the bunch of static files before getting the recent splash screen plugin.
I didn’t quite understand what actions are required for my part, I thought the plugin would handle all this. Should I set the files on Xcode? I don’t have access to all iOS devices to know what’s going to happen

I have the same problem with iPhone 7, if I used older version (2017.3025) I receive the following values

Version 2017.3025

on Corona Simulator

     pixelWidth, pixelHeight      ->    750x1334

 

on iPhone 7

     pixelWidth, pixelHeight      ->    640x1136 ( wrong value )

 

Version 2017.3058

on Corona Simulator

     pixelWidth, pixelHeight      ->    750x1334

 

on iPhone 7

     pixelWidth, pixelHeight      ->    640x960 ( wrong value )

You don’t have your launch images setup correctly. See: https://docs.coronalabs.com/guide/distribution/launchFile/index.html

Note there are two ways to do this. If you’re using 3025, that still supports iOS 6 and iOS 7 and as such you should use the Static Image method at the bottom of the docs. If you choose to use a later daily build like 3058, we recommend you switch to the Storyboard method that Apple prefers (top of the doc) since later builds dropped support for iOS 6 and 7 and we can eliminate multiple huge PNG files that have to be named exactly right and match a specific size for each device you want and go with three smaller, images and one line of code in build.settings.

Rob

Rob is this needed if using the paid splash screen plugin?

Apple still requires a Default-568h@2x.png file that is 640x1136 pixels, portrait orientation or your app goes into iPhone 4 mode. Our simulator does not emulate that behavior. Then if you’re using an iPhone 6/6s/7 Apple also requires a Default-667h@2x.png file to break out of iPhone 5 compatibility mode and for the iPhone 6 plus/ 6s plus/7 plus, you have to have a Default-736@3x.png file – if you are using Static UILaunchImages.  This precedes the Corona splash screen.

You can avoid all of that complexity by going with Storyboard based launch images as linked to above.

Android has no concept of a launch image, so the startup sequence is:  Corona Labs Splash Screen -> First rendered frame from main.lua

However iOS does and the startup sequence is:  UILaunchImage -> Corona Splash Screen -> First rendered frame.

We have no way of disabling Apple’s UI launch images.  One of the simplest things to do is to use a totally black UI launch image.

Rob

Thanks Rob,

Adding UILaunchStoryboardName = “LaunchScreen” in build.setting file I solved the problem.

Stefan

Try adding a png called Default-568h@2x.png to your build.  This forces the proper view.  Although there is talk of this being replaced.  Perhaps Corona can chime in here.

It worked!

Will this affect only the iPhone 5 or I should be worried with the others?

thanks

Just iphone 5 AFAIK

So do I have to put other images for the other screen sizes?

No, just that specific texture and for iPhone 5.

It is because of a legacy feature/rule associated with the switch between iPhone4 resolution/aspect ratio and the new (at the time) iPhone 5 resolution & aspect ratio.

I believe at the time, this was a quick way for users to re-release their apps and tell the OS, “I’ll handle scaling”.  i.e. If a legacy app was opened on iPhone5 when it first came out it would stretch to fit the screen.  My memory may be faulty here, but I think that is what happened.

As you can imagine, when the iPhone 5 came out and all the apps were designed for 320x480 and 640x960 it was a bit of a challenge for developers to update their apps.

Ok then. Thanks for the clarifications