ios 在 iPhone X 模拟器的顶部和底部看到黑条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46184859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:26:00  来源:igfitidea点击:

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

iosuinavigationbarios-simulatorxcode9iphone-x

提问by Darko

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

在 iPhone X Simulator (GM Seed) 中运行我的应用程序我注意到两个奇怪的效果:

  • the App does not use the full screen space (top and bottom area is black)
  • a strange white bar beneath the title bar
  • 该应用程序不使用全屏空间(顶部和底部区域为黑色)
  • 标题栏下方有一个奇怪的白色栏

enter image description here

在此处输入图片说明

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

有谁知道这里发生了什么以及如何解决这个问题?我在 Interface Builder 中找不到任何新设置。

回答by 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.

新的 iPhone X 需要一张大小为 1125px × 2436px 的启动图像,即 375pt × 812pt 的 3x 图像。

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.

当然,如果您切换到使用启动屏幕文件而不是单个启动图像,您的应用程序将自动适应所有设备尺寸,无需任何额外工作。

回答by Karthickkck

I have figured out this issues in iPhone X. Launch image size (1125*2436px) Please flow this below steps. 1.i)Choose your project name in Xcode. ii)Select your project target iii)Then select Launch images source enter image description here

我已经在 iPhone X 中解决了这个问题。启动图像大小 (1125*2436px) 请按照以下步骤进行操作。1.i) 在 Xcode 中选择您的项目名称。ii)选择您的项目目标 iii)然后选择启动图像源 在此处输入图片说明

  1. You can get Migrate popup i) Choose Assets ii)Select Migrate
  1. 您可以获得迁移弹出窗口 i) 选择资产 ii) 选择迁移

enter image description here

在此处输入图片说明

  1. After that select your Assets.xcassets in your project enter image description here

  2. Then select Launch image in assets i)Then select attribute inspectorenter image description here

  3. finally check your Launch image source. you can see set Launch image.

  1. 之后在你的项目中选择你的 Assets.xcassets 在此处输入图片说明

  2. 然后选择 Launch image in assets i)然后选择属性检查器在此处输入图片说明

  3. 最后检查您的 Launch 图像源。你可以看到设置启动图像。

enter image description here

在此处输入图片说明

回答by Lal Krishna

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

iPhone X 需要不同的启动图像大小为 1125px x 2436px (375pt x 812pt @3x)。

enter image description here

在此处输入图片说明

Check human interface guidelinesfor more details.

查看人机界面指南以获取更多详细信息。

回答by 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.

我已经想出了如何修复(虽然我仍然不明白为什么这只会发生在 iPhone X 上)在 iPhone X 上的 LaunchScreen 故事板看到黑色的顶部和底部栏。

I have LaunchScreen storyboard with one UIImageView.

我有一个带有一个 UIImageView 的 LaunchScreen 故事板。

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

UIImageView 的top&bottom必须固定到SuperView 的top&bottom。不要到SafeArea

回答by Arbitur

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

我通过简单地在文本Lanch Screen File字段中插入一些随机文本来修复它。我什至没有启动屏幕文件……XCode 太有问题了。

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"

尽管这在模拟器中修复了它(仍然非常奇怪和意外),但在将二进制文件上传到 iTunes Connect 时它会失败,因为找不到名称为“random-name”的 LanchScreen 文件

回答by 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:

在 Xcode 9.4 上,我可以通过执行以下操作来解决此问题:

  1. Add a launch screen by going to File -> New -> File... -> Launch Screen
  1. 通过转到 File -> New -> File... -> Launch Screen 添加启动屏幕

enter image description here

在此处输入图片说明

  1. Make sure the newly added launch screen storyboard is selected as the launch screen file under project settings.
  1. 确保在项目设置下选择新添加的启动屏幕故事板作为启动屏幕文件。

enter image description here

在此处输入图片说明

回答by 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.

刚刚遇到这个问题......当我选择项目和正确的目标时,我在应用程序图标和启动屏幕图像选项卡下的“启动屏幕文件”中有一个空白。我将它设置为默认的 LaunchScreen,并且解决了我面临的调整大小问题。

回答by 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.

如果您已经有一个 1125px × 2436px 的启动图片,但应用程序仍然没有使用全屏检查来确保您的图片是 PNG。

回答by 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

如果您删除了 LaunchScreen.storyboard;选择你的项目,选择你的项目目标,General -> App Icons and Launch Images -> Launch Screen File:在这里选择 Main.storyboard 而不是 LaunchScreen.storyboard

回答by Aqib Zareen

You may check in project target launch screen file is not set to empty if it is empty it may cause problem.enter image description here

您可以签入项目目标启动屏幕文件未设置为空如果它是空的它可能会导致问题。在此处输入图片说明