@3x images incorrectly used on iPhone 6 or 5S or 5

2019-05-22 14:47发布

With-in a clean brand new iOS project I've:

  • added 2 images to the project "background@2x.png" and "background@3x.png"
  • added a XIB named "LaunchScreen.xib"
  • checked the XIB's "Use as Launch Screen" option
  • added a UIView sub-view to LaunchScreen.xib and set its image name to "background.png"
  • with-in the project settings, under the targets 'General' settings I've set the 'Launch Screen file' to "LaunchScreen"

Now when I launch the app on any of the devices list below the @3x image is displayed in the resulting launch screen when surely the @2x image should be used.

Problem devices (that all use the @3x resource):

  • iPhone 5 (iOS 8.0.0)
  • iPhone 6 (iOS 8.0.0)
  • iPhone 6 (iOS 8.0.2)
  • iPhone 5 Simulator (iOS 8.0.0)
  • iPhone 6 Simulator (iOS 8.0.0)

NOTE that the @2x image is distinctive from the @3x image so I can easily identify which one is being used.

At first I assumed this was a bug with the simulator and was staggered when it occurred on a real device also.

I assume this is yet another iOS8 bug however I guess there's also the possibility that its expected behaviour as the result of the launch screen being cached as a static image of some kind.

Any ideas or potential solutions?

EDIT:

For the benefit of others, I have subsequently found that if the images are instead added to an Images.xcassets image set then the correct behaviour is in-fact observed. HOWEVER this is not an ideal solution for us since we have a very specific image export process which means we are not using an Images.xcassets in out project (there are thousands of images in the app).

I have now also raised a Radar with Apple #18513968

http://openradar.appspot.com/18513968

1条回答
迷人小祖宗
2楼-- · 2019-05-22 15:36

I've just tried this myself, and get the same behaviour you have mentioned.

By setting the Launch Images Source to "Use Asset Catalog", and adding the Launch Image you can get each device to show its specific background. Some screenshots can be seen here:

Supporting iPhone 6 and iPhone 6+ with different launch/splash screen image for iPad Portrait and Landscape orientations

Looking into it a bit more, I found a website that mention:

http://oleb.net/blog/2014/08/replacing-launch-images-with-storyboards/

"You can use the new adaptive UI features in Interface Builder to fit your layout to different screen sizes. If your scene requires screen-size-specific images, use asset catalogs to define different images per size class."

Maybe that is the only way to do it.

查看更多
登录 后发表回答