App launches in full screen in simulator, but not

2020-02-10 07:50发布

问题:

This is an Xcode 6 Swift project. When choosing iPhone 5 or 5s in the simulator, the app launches at full screen height. However, when running the app on an actual device (an iPhone 5s), the screen is only iPhone 4 in height (i.e. black bars appear at the top and bottom of the screen).

The strange thing is that I've re-created this project from another test project - and in the original project I didn't have this problem.

I've performed a text-compare on the storyboard xml files for each, and both are mostly identical. I've also looked at the Build Settings for each, and can't see any obvious differences. Finally, the json files specified in the "Images.xcassets" directory for each are the same.

回答1:

Managed to fix the problem. In the General settings for the target, under "App Icons and Launch Images" I clicked the "Use Asset Catalog" button and followed the options.



回答2:

Place the Launch screen images for both iphone 5 and iphone 4 . Put the size of the default-568@2x image as 640 x 1136 .

May be you missed this size of splash screen in your project.



回答3:

For me it was fixed after adding the images with all sizes



回答4:

For me, this was because I'd saved the file in photoshop format, but with a PNG extension. The emulator loaded the file, but the actual device couldn't. Wasted 3 hours messing with asset catalogs before I figured it out!

Blog post on subject