ChatGPT解决这个技术问题 Extra ChatGPT

Seeing black bars at the top and bottom of the iPhone X Simulator

Running my App in the iPhone X Simulator (GM Seed) I am noticing two strange effects:

the App does not use the full screen space (top and bottom area is black)

a strange white bar beneath the title bar

https://i.stack.imgur.com/mMMvmm.jpg

Does anybody know what is happening here and how to resolve this? I can't find any new settings in Interface Builder.

Are you using a Launch Screen file or launch images? Are you using auto layout?
Launch images and auto layout
Why are you using the old style launch images instead of the much easier Launch Screen file? Anyway, have you added the new launch image needed for the new screen size?
I can't find a launch image for the iPhone X size. But using a launch screen solved both issues. Please edit your response and I will mark it as answered. Thanks!
You SHOULDN'T USE launch images. USE Launch Screen.storyboard instead

r
rmaddy

When using launch images (instead of the much easier Launch screen file), you need to provide the properly sized launch image for each device size you wish to support. Once you add the additional launch image, your app should take advantage of the new screen size.

The new iPhone X requires a launch image sized at 1125px × 2436px which is a 3x image for 375pt × 812pt.

Of course if you switch over to using a Launch screen file instead of individual launch images, your app will automatically adapt to all device sizes without any additional work.


can you go into more detail on how to integrate the new iphoneX image into a Launch Screen? Any Image Sets I add to Xcode 9 don't have iphoneX slots, only Launch Image sets.
@ChristianCerri Image sets are not tied to devices. They just give you 1x, 2x, and 3x options. I was referring to launch images. Those are the only device specific images. If you have a question about adding different sized images to a Launch screen then please post your own question specific to that issue.
How the hell launch images related to blackbar on top and bottom of iPhone X simulator ??!
@TomSawyer If your app doesn't use a Launch screen storyboard then the launch images determine what screen sizes your app supports.
See answer from @sabiland if you're still seeing black bars and using a launch screen. Would be great if this answer could be supplemented with the tidbit about how to design the launch screen properly for iPhone X.
K
Karthick C

https://i.stack.imgur.com/SqnuV.png

You can get Migrate popup i) Choose Assets ii)Select Migrate

https://i.stack.imgur.com/GgOMf.png

After that select your Assets.xcassets in your project Then select Launch image in assets i)Then select attribute inspector finally check your Launch image source. you can see set Launch image.

https://i.stack.imgur.com/27jLU.png


Upvoted for the pictures. But you should clear out the "LaunchScreen" Text from the Launch Screen File text field in your last image.
Thank's @NadtheVlad. Please clear the "LaunchScreen" text from Launch Screen File and delete LaunchScreen.Storyboard file from Xcode.
Thanks! It was landscape checkbox from Launch Image that was causing problem since my app is only portrait.
Thank you, had the same issue and resolved it by adding launch images (an SDL2 application)
L
Lal Krishna

iPhone X needs different launch image sized 1125px x 2436px (375pt x 812pt @3x).

https://i.stack.imgur.com/BUfJd.png

Check human interface guidelines for more details.


s
sabiland

I have figured out how to fix (though I still don't understand why this happened only on iPhone X) LaunchScreen storyboard on iPhone X with seeing black top&bottom bars.

I have LaunchScreen storyboard with one UIImageView.

UIImageView's top&bottom has to be pinned to SuperView's top&bottom. NOT to SafeArea.


This solved my problem with LauchScreen with Autolayout. But instead of pin to the borders, I centered horizontally and vertically and equal the width/height to SuperView.
This only worked after also pinning views in other storyboards to the view top/bottom as opposed to the layout guides. Be sure to check storyboards while in iPhone X mode.
why i can't see superview in my storyboard when i go to give that constraint
A
Arbitur

I fixed it by simply inserting some random text in the Lanch Screen File textfield. I dont even have a Launch Screen File... XCode is so buggy.

update

Although this fixes it in simulator (still very weird and unexpected) when uploading a binary to iTunes Connect it will fail due to not finding a LanchScreen file of name "random-name"


Right its working for iphone x . but its not working for any other devices bro.
Yes yes! this fixes it in xcode. Thanks! That's good enough for testing. Will buy a real iphone X to avoid the xcode issue in future to test on.
M
Myxtic

Just ran into this while trying to update an app I hadn't worked on in a while.

On Xcode 9.4, I was able to fix this by doing the following:

Add a launch screen by going to File -> New -> File... -> Launch Screen

https://i.stack.imgur.com/jEPyD.png

Make sure the newly added launch screen storyboard is selected as the launch screen file under project settings.

https://i.stack.imgur.com/t1UMG.png


B
Blago

If you already have a 1125px × 2436px launch image but the app is still not using the full screen check to make sure that your image is PNG.


B
Bedri Keskin

if you removed LaunchScreen.storyboard; Choose your project, select your project target, General -> App Icons and Launch Images -> Launch Screen File: Select here Main.storyboard instead of LaunchScreen.storyboard


R
Revanth Matha

Just had this problem... When I selected the project & the correct target I had a blank for the 'launch screen file' under the app icons and launch screen images tab. I set it to the default LaunchScreen and the resizing issue I faced was taken care of.


A
Aqib Zareen

https://i.stack.imgur.com/KZ3hw.jpg


P
Prabakaran Muthusamy

Yes me too face that top spacing issue in iOS 15,

iOS 15 needs some new size of the Launch images

So you please check your all the launch screen images

Check your Attribute inspector is portrait for Launchscreen

https://i.stack.imgur.com/TIC9k.png