简体   繁体   English

iOS 9 xCode 7内置应用程序显示黑色矩形而不是启动屏幕

[英]iOS 9 xCode 7 built app displays black rectangle instead of splash screen

I know this question may seem like a duplicate of a few existing ones but its not. 我知道这个问题似乎是几个现有问题的重复,但事实并非如此。

I am struggling with this issue where universal (iPad/iPhone) application does not display the splash screen anymore. 我正在为通用(iPad / iPhone)应用程序不再显示初始屏幕的问题而苦苦挣扎。

Before upgrading to iOS 9 and Xcode 7, no such issues were present. 在升级到iOS 9和Xcode 7之前,不存在此类问题。 After upgrading no changes were made to the splash screen in any way. 升级后,没有对启动屏幕进行任何更改。

Tech data relevant to the question: 与问题相关的技术数据:

  • Supported devices are iPad (landscape only) and iPhone (portrait/landscape) 支持的设备是iPad(仅横向)和iPhone(纵向/横向)
  • I use "Launch Screen.xib" that has an UIImageView with size classes and constraints set up so that it's always full screen. 我使用“ Launch Screen.xib”,它具有一个UIImageView,其中设置了尺寸类和约束,因此它始终是全屏的。
  • I have added all splash screen images in image assets (except iPad Portrait ones) 我已将所有初始屏幕图像添加到图像资源中(iPad Portrait图像除外)
  • I use Xcode Version 7.0.1 (7A1001) and iOS 9.0.2 我使用Xcode版本7.0.1(7A1001)和iOS 9.0.2
  • This issue does not happen on an iPad 在iPad上不会发生此问题

The wrong splash screen looks like this on iPhone 5s: iPhone 5s上的错误启动画面看起来像这样: iPhone5S显示错误的启动画面

This is made in portrait mode, so there are white squares on top and on bottom of this "black square". 这是在纵向模式下完成的,因此此“黑色方块”的顶部和底部都有白色方块。

I was struggling with this issue yesterday but I managed to fix it by renaming my launch screen to "LaunchScreen.xib" (without the space). 我昨天在这个问题上苦苦挣扎,但设法通过将启动屏幕重命名为“ LaunchScreen.xib”(没有空格)来解决了这个问题。 But this morning the issue re-appeared. 但是今天早上这个问题又出现了。

Things I've tried: 我尝试过的事情:

  • Removing and creating LaunchScreen.xib again with and without space 再次删除并创建有空间和无空间的LaunchScreen.xib
  • Creating LaunchScreen.storyboard file instead of xib 创建LaunchScreen.storyboard文件而不是xib
  • Adding @2x and @3x versions of image used in LaunchScreen.xib 添加LaunchScreen.xib中使用的@ 2x和@ 3x版本的图像
  • Removing/adding/replacing images in image assets 删除/添加/替换图像资产中的图像
  • Cleaning, build cleaning and even deleted derived data 清理,构建清理,甚至删除派生数据
  • Restarting device, reinstalling app, relaunching without building and many other solutions that I could think of. 重新启动设备,重新安装应用程序,无需构建便重新启动以及我想到的许多其他解决方案。

Nothing helped, so maybe someone fixed a similar issue already and can lead me to the right direction. 没有任何帮助,所以也许有人已经解决了类似的问题,并且可以将我引向正确的方向。

EDIT 1 编辑1

So I renamed my LaunchScreen.xib image used from "Default.png" to "DefaultSplash.png". 因此,我将使用的LaunchScreen.xib图像从“ Default.png”重命名为“ DefaultSplash.png”。 This instantly fixed all issues on iPhone. 这可以立即修复iPhone上的所有问题。 But now I have a new problem - iPad splashscreen is now black . 但是现在我有一个新问题-iPad启动屏幕现在是黑色的 If I set the LaunchScreen image to some other image used in project, the Ipad displays it as splashscreen without any problems, but neither Default.png nor DefaultSplash.png can be used on ipad now. 如果我将LaunchScreen图像设置为项目中使用的其他图像,则Ipad可以将其显示为启动屏幕,而不会出现任何问题,但是Default.png和DefaultSplash.png现在都不能在ipad上使用。 This is really weird issue. 这真是一个奇怪的问题。

So I fixed the issue like this: 所以我解决了这样的问题:

Since I renamed the file LaunchScreen.xib , it fixed an issue on iPhone but caused a similar problem on iPad . 自从我将文件重命名为LaunchScreen.xib ,它解决了iPhone上的一个问题,但在iPad上引起了类似的问题。 Since then, I cannot use the same image file name for the same xib (ie if image "Default.png" failed, it cannot be used anyomre... Bug?). 从那时起,我不能为相同的xib使用相同的图像文件名(即,如果图像“ Default.png”失败,则不能使用它...错误?)。 So I created two files, LaunchScreen.xib and LaunchScreen~iphone.xib with separate image files for each. 因此,我创建了两个文件LaunchScreen.xibLaunchScreen~iphone.xib ,每个文件都有单独的图像文件。 Now it works okay. 现在可以了。

Seems ugly and buggy but it works. 看起来很丑陋,但确实可行。

In my case the images in the "Launch Screen.xib" weren't displaying. 就我而言,“启动Screen.xib”中的图像没有显示。 I had to rename them and reset the new names in the nib file to make it work. 我不得不重命名它们并在nib文件中重置新名称以使其正常运行。

There is a change in Xcode7 iOS 9 onwards. Xcode7 iOS 9及更高版本有所变化。 They have modified Launchscreen(Black screen we will get).If you change deployment target means you can see the previous launch screen. 他们已经修改了启动屏幕(我们将得到黑屏)。如果您更改部署目标,则可以看到先前的启动屏幕。 Only empty view controller is present so we have make changes on it. 仅存在空的视图控制器,因此我们对其进行了更改。 As per requirement in assets add images in imagecassets. 根据资产中的要求,将图像添加到图像集中。

It may sound stupid but something related to this scenario may happen: 听起来可能很愚蠢,但可能会发生与这种情况有关的事情:

If you hook any outlet and then break it by changing the custom class you will get this black screen behavior without any warning, instead of the typical crash from any non launch storyboard/scenes this will lead to a black screen before the app start. 如果您钩住了任何插座,然后通过更改自定义类破坏了插座,则将在没有任何警告的情况下得到此黑屏行为,而不是任何非启动情节提要/场景造成的典型崩溃,这将导致在应用启动之前出现黑屏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM