iOS 9 Xcode 7 - 应用程序在顶部和底部出现黑条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32641240/
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
iOS 9 Xcode 7 - Application appears with black bars on top and bottom
提问by Mojtaba
Installed the app on iPhone 6 iOS9 and here is what happened. Notice black bars on top and bottom. It works just fine on iOS8. How I can fix it?
在 iPhone 6 iOS9 上安装了该应用程序,这就是发生的事情。注意顶部和底部的黑条。它在 iOS8 上运行良好。我该如何解决?
I've tried building with Xcode 6.4 & 7. Same result.
我试过用 Xcode 6.4 & 7 构建。结果相同。
(iPhone 5 used to run iPhone 4 apps like this)
(iPhone 5 曾经运行过这样的 iPhone 4 应用程序)
回答by Gruntcakes
Did you migrate your app from an earlier version of Xcode? If so then Xcode is now making an assumption about your screen size and you need a way of indicating the actual screen size at run time.
您是否从早期版本的 Xcode 迁移了您的应用程序?如果是这样,那么 Xcode 现在正在对您的屏幕尺寸进行假设,并且您需要一种在运行时指示实际屏幕尺寸的方法。
There are two ways:
有两种方式:
a) If you use a launch screen.
a) 如果您使用启动屏幕。
You are missing a LaunchScreen.storyboard file. Create a LaunchScreen.storyboard file and add it to your project.
您缺少 LaunchScreen.storyboard 文件。创建 LaunchScreen.storyboard 文件并将其添加到您的项目中。
b) If you don't use a launch screen.
b) 如果您不使用启动屏幕。
Go to your Target's settings and choose General, then App Icons and Launch Images. Now set "Launch Screen File" to your "main.storyboard" (or another storyboard if appropriate)
转到 Target 的设置并选择“常规”,然后选择“应用程序图标”和“启动图像”。现在将“启动屏幕文件”设置为“main.storyboard”(或其他故事板,如果合适)
回答by dreamer.psp
My App does not use a launch image. Setting the "Launch Screen File" to my "main.storyboard" file fixed the issue for me.
我的应用程序不使用启动图像。将“启动屏幕文件”设置为我的“main.storyboard”文件为我解决了这个问题。
This setting can be found under "Target->General->App Icons and Launch Images"
此设置可以在“目标->常规->应用程序图标和启动图像”下找到
Use the following link for more information: http://oleb.net/blog/2014/08/replacing-launch-images-with-storyboards/
使用以下链接了解更多信息:http: //oleb.net/blog/2014/08/replacing-launch-images-with-storyboards/
回答by smapps
For me the problem is i'm migrating my app from earlier version of Xcode and the project is missing LaunchScreen.storyboard file. I have just created LaunchScreen.storyboard and added it to launch Screen File. This did the trick.
对我来说,问题是我正在从早期版本的 Xcode 迁移我的应用程序,并且项目缺少 LaunchScreen.storyboard 文件。我刚刚创建了 LaunchScreen.storyboard 并将其添加到启动屏幕文件中。这成功了。
回答by Max Hiroyuki Ueda
I'm using xcode 7.2 . At first, I created a LaunchScreen.storyboard file, as Potassium Permanganatesuggested, and it worked! However, I didn't want a launch screen, so I tried setting Main.storyboard as Launch Screen File and it did the trick!
我正在使用 xcode 7.2 。起初,我按照高锰酸钾的建议创建了一个 LaunchScreen.storyboard 文件,并且成功了!但是,我不想要启动屏幕,所以我尝试将 Main.storyboard 设置为启动屏幕文件,它成功了!
回答by Himanshu Mahajan
When you migrate your app from earlier version of xCode to xCode 6 or xCode 7, you will face this issue.
当您将应用程序从早期版本的 xCode 迁移到 xCode 6 或 xCode 7 时,您将面临此问题。
For iOS 7 and earlier, developers need to provide separate launch images for all screen sizes, resolutions and orientations their app supported.
对于 iOS 7 及更早版本,开发人员需要为其应用支持的所有屏幕尺寸、分辨率和方向提供单独的启动图像。
In Xcode 6 or later, there is another option. You can specify a storyboard whose initial view controller will then be used as the app's launch screen. Use below steps:
在 Xcode 6 或更高版本中,还有另一种选择。您可以指定一个故事板,其初始视图控制器将用作应用程序的启动屏幕。使用以下步骤:
Create a blank storyboard file named LaunchScreen.storyboard.
Go to your target settings and, on the "General" tab, select the storyboard as your Launch Screen File in "App Icons and Launch Images" section. Xcode will add a corresponding UILaunchStoryboardName key to your app's Info.plist. When this key is present, Xcode will prioritize it over any launch images you might have set.
- Add some subviews to newly created storyboard's view and position them with constraints. When you launch the app on a device, the OS should use the scene as the launch screen.
创建一个名为 LaunchScreen.storyboard 的空白故事板文件。
转到您的目标设置,然后在“常规”选项卡上,选择故事板作为“应用程序图标和启动图像”部分中的启动屏幕文件。Xcode 会将相应的 UILaunchStoryboardName 键添加到您的应用程序的 Info.plist。当此键存在时,Xcode 将优先于您可能设置的任何启动图像。
- 将一些子视图添加到新创建的故事板视图并使用约束定位它们。当您在设备上启动应用程序时,操作系统应使用场景作为启动屏幕。
Delete the older app from simulator and clean the project.
从模拟器中删除旧的应用程序并清理项目。
Cheers :-)
干杯:-)
回答by VDPATEL
I have same issue in my app . In my app i have multiple targets added to project . If i use launch storyboard solution then i can see full screen but in my case my Lunch image looks blurred and stretched on iPhone 4 . To come out from this issue I have used LaunchImage asset solutions . After this still I am facing same issue .I have tried all above solutions, At end I found my png images don't include ALPHAresolutions . After adding new images ,i can see full screen images .
我的应用程序中有同样的问题。在我的应用程序中,我将多个目标添加到 project 。如果我使用启动故事板解决方案,那么我可以看到全屏,但在我的情况下,我的午餐图像在 iPhone 4 上看起来模糊和拉伸。为了解决这个问题,我使用了 LaunchImage 资产解决方案。在此之后,我仍然面临同样的问题。我已经尝试了上述所有解决方案,最后我发现我的 png 图像不包括ALPHA分辨率。添加新图像后,我可以看到全屏图像。
回答by Shakeel Ahmed
回答by Mohcine Belarrem
Go to the asset catalog and create a new iOS launch Image. then in Target>General>App Icons and Launch Images>Launch Image Sourceyou will see automatically the new Launch Image created in the assets catalog.
转到资产目录并创建一个新的 iOS 启动图像。然后在Target>General>App Icons and Launch Images>Launch Image Source 中,您将自动看到在资产目录中创建的新 Launch Image。
回答by d.rozumeenko
In my case, I have several targets in the project and each one has it's own launch screen images. The weird thing one of the targets looks fine but others have those black bars. The thing was in the name of Launch folder inside assets. Change name to LaunchImage solves the problem.
就我而言,我在项目中有多个目标,每个目标都有自己的启动屏幕图像。奇怪的是,其中一个目标看起来不错,但其他目标却有那些黑条。事情是在资产中启动文件夹的名称中。将名称更改为 LaunchImage 可以解决问题。
回答by Wils
In my case I have one asset with launch images however it was displaying the top and bottom dark bar as well.
在我的情况下,我有一个带有启动图像的资产,但是它也显示了顶部和底部的暗条。
I've tried the launch storyboard solution and yes it works but I didn't want to add a new file so, this is what I did to fix the issue:
我已经尝试了启动故事板解决方案,是的,它可以工作,但我不想添加新文件,因此,这是我为解决问题所做的工作:
- Copied my launch images to another folder
- Removed the existing LaunchImage asset
- Added a new LaunchImage asset
- Added the images to the new LaunchImage
- 将我的启动图像复制到另一个文件夹
- 删除了现有的 LaunchImage 资产
- 添加了一个新的 LaunchImage 资产
- 将图像添加到新的 LaunchImage
That's it!
就是这样!