启动iOS应用程序中未显示的图像(使用Image .xcassets)

时间:2022-09-10 20:34:03

I'm having some trouble getting my launch image to show up in my application.

在我的应用程序中,我的启动镜像出现了一些问题。

I have created all the static image files in the Images.xcassets file in an asset set called "LaunchImage".

我已经创建了图像中的所有静态图像文件。在名为“LaunchImage”的资产集中的xcassets文件。

I noticed that my project also contains a LaunchScreen.xib file (which was automatically created by Xcode).

我注意到我的项目也包含一个启动屏幕。xib文件(由Xcode自动创建)。

This .xib file appears when I run the application on my iPhone6 device. It doesn't appear in the simulator for iPhone4s (which makes sense, since xib launch screen is only for iOS 8 +).

当我在iPhone6设备上运行应用程序时,会出现这个.xib文件。它没有出现在iPhone4s的模拟器中(这是有意义的,因为xib启动屏幕只适用于iOS 8 +)。

I want to use the static images that I have created since they fall under the Apple Guidelines and go with my application. However, I haven't had any luck at getting it to show up.

我想使用我创建的静态图像,因为它们是在苹果的指导方针下使用的,并与我的应用程序一起使用。然而,我没有任何运气能让它出现。

I noticed under the project settings that there is a section called App Icons and Launch Images. I see how the .xib is connected by the Launch Screen File option I assume.

我注意到在项目设置下有一个叫做App图标和启动图像的部分。我看到.xib是如何通过启动屏幕文件选项连接的。

However, there is an option called Launch Image Sources. What does this do?

然而,有一个选项叫做发射图像源。这做什么呢?

I found this: http://matthewpalmer.net/blog/2014/09/10/iphone-6-plus-launch-image-adaptive-mode/. However, it didn't explain anything about the Launch Image Source option.

我发现这:http://matthewpalmer.net/blog/2014/09/10/iphone-6-plus-launch-image-adaptive-mode/。然而,它并没有解释发射图像源选项。

There is a button next to the Launch Image Sources called "Use Asset Catalog". When I click it, it just says Migrate Launch Images to an asset catalog. Your existing launch images will be copied into a new image set. Choose an asset catalog to use: .

在启动映像源旁边有一个按钮,名为“使用资产目录”。当我点击它时,它只是说将启动图像迁移到资产目录。您现有的启动映像将被复制到新的映像集中。请选择要使用的资产目录:。

This is confusing to me because I've already created my asset catalog and I definitely don't want it to overwrite images.xcassets file. So, how do I link this to the Launch Images Asset Set that I already have created? Also what "existing launch images" is it referring to will be copied into a new image set?

这让我感到困惑,因为我已经创建了我的资产目录,我绝对不希望它覆盖图像。xcassets文件。那么,如何将它与我已经创建的Launch Images资产集关联起来呢?它所指的“现有发射图像”将被复制到一个新的图像集?

Thank you!

谢谢你!

UPDATE 1

更新1

So, I tried the migrate images option and chose to the new set option. This caused a new image set to be created which I deleted. However, the name left in the Launch Image Source was set to LaunchImage which somehow connected to the image set that contains my launch images. It did mess up my LaunchImage set -- the images were set to unassigned. I deleted them and dragged my files to the appropriate box in the LaunchImage asset set. However, when I run the application it still doesn't work. =( Launch Image doesn't show up.

因此,我尝试了migration images选项并选择了新的set选项。这将创建一个新的映像集,并将其删除。但是,在发射图像源中留下的名称被设置为LaunchImage,它以某种方式连接到包含我的发射图像的图像集。它确实把我的LaunchImage设置搞砸了——这些图片被设置为unassigned。我删除了它们,并将文件拖到LaunchImage资产集中相应的框中。=(发射图像未显示。

I even removed the information that was in Launch Screen File (which my assumption was the setting that connects to the .xib file). Still, somehow the .xib file appears on my iPhone6 device. =(

我甚至删除了启动屏幕文件中的信息(我的假设是连接到.xib文件的设置)。不过,不知何故,.xib文件出现在我的iPhone6设备上。=(

Any ideas what's going on?

有什么想法吗?

8 个解决方案

#1


50  

I had this problem. I tested on simulator. I left the "Launch screen file" blank and removed the line about the "launch screen file" inside the plist. I restarted Xcode. Nothing. In my case in was not black it was white. Xcode 7 target ios 9.

我有这个问题。我在模拟器测试。我将“启动屏幕文件”留空,并删除了plist中有关“启动屏幕文件”的行。我重新启动Xcode。什么都没有。我的箱子里不是黑色的,是白色的。Xcode 7针对ios 9。

i read this one as well: Launch Image does not show up in my iOS App

我也读过这个:在我的iOS应用中没有显示启动图像

The launch image only showed up when i deleted the app from the simulator and run the app again.

只有当我从模拟器中删除应用程序并再次运行应用程序时,才会出现启动图像。

#2


37  

I finally figured it out!

我终于明白了!

So, in your project settings, go to the section that says: App Icons and Launch Images

所以,在你的项目设置中,转到“应用图标”一栏,启动图片

Remove the information found in Launch Screen File if you do not want to use .xib file.

如果不想使用.xib文件,请删除启动屏幕文件中找到的信息。

Then, in Launch Image Source, Choose to migrate and if you have already created your LaunchImage file and added the images to it. Then click the asset catalog that shows up. The name of the one that contains your Launch Images.

然后,在启动映像源代码中,选择迁移,如果您已经创建了LaunchImage文件并将映像添加到该文件中。然后单击出现的资产目录。包含你的发射图像的那个的名字。

This will create a new Launch-Image2 in your image set. To use the one you already have created, click the drop-down menu next to Launch Image Source. And you should see your other Launch Image set. Choose it. Then re-build your application and run it. You should see your Launch Image. =)

这将在您的映像集中创建一个新的Launch- image2。要使用您已经创建的那个,请单击next启动图像源的下拉菜单。你应该看到你的另一个发射图像集,选择它。然后重新构建应用程序并运行它。你应该看到你的发射图像。=)

Hope this helps!

希望这可以帮助!

Note: it won't delete your images that you already have in the asset catalog. It will just create a new LaunchImage asset set.

注意:它不会删除资产目录中已有的映像。它将创建一个新的LaunchImage资产集。

Reference: https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/chapters/StoringAppIconsandLaunchImagesinanAssetCatalog.html

参考:https://developer.apple.com/library/ios/recipes/xcode_help chapters/storingappiconsandlaunchimagesinanassetcatalog.html——image_catalog - 1.0 /

#3


23  

This is too important !

这太重要了!

should be empty ! Launch Screen File

应该是空的!启动屏幕文件

启动iOS应用程序中未显示的图像(使用Image .xcassets)

#4


9  

  • Make sure your images are accurate size according to Apple guidelines.
  • 根据苹果的指导方针,确保你的图片尺寸准确。
  • Make sure, You will select only one option , either launch screen file or Launch Image Source. You can find these two options in Project build settings -> General
  • 确保您将只选择一个选项,要么启动屏幕文件,要么启动图像源。您可以在项目构建设置中找到这两个选项——> General

Clean and build

清洁和构建

My suggestion to you is to select Launch Image Source as Image.Assets. Create splash image assets there in Image.assests folder. Must Clear the text in Launch screen file.

我的建议是选择Launch Image Source as Image. assets。在图像中创建溅出的图像资产。资产近文件夹。必须清除启动屏幕文件中的文本。

Reference image for right configuration: 启动iOS应用程序中未显示的图像(使用Image .xcassets)

正确配置参考图像:

#5


1  

Had a similar issue today. Tried to let xCode create automatically the Asset, but it was always unassigned.

今天也有类似的问题。尝试让xCode自动创建资产,但总是没有分配。

The solution was to create manually the Launch Image in the ImageAsset and assign the files for his respective resolution.

解决方案是在ImageAsset中手动创建发射映像,并为其各自的分辨率分配文件。

It looks like xCode created a different type of Launch Image asset, so it didn't recognized the asset (v8.3.2)

看起来xCode创建了不同类型的启动映像资产,所以它没有识别该资产(v8.3.2)

#6


0  

I just figured this out. My launch image was not showing up, I get a white screen when launching on a device (iPhone 6, 7+) or testFlight. Fix: Renamed "Landing_screen.png" to just "Landing_screen" removing .png part. https://*.com/a/43592662/3445278

我刚刚算出来了。我的发射图像没有显示出来,当我在一个设备(iPhone 6, 7+)或testFlight上发射时,我得到了一个白色的屏幕。解决办法:重新命名为“Landing_screen。png“只”到“Landing_screen”删除。png部分。https://*.com/a/43592662/3445278

#7


0  

Solved! I've tried a lot. The problem was that the launch image shows in simulator and didn't show in real device. I got a Storyboard with UIImageView in it. Strange was that old images worked, and images, that i did add recently not. First i thought that this is a problem with assets. No. Than i checked color profiles and did a lot of tries with different profiles: left-working image, right-not working. Didn't help. 启动iOS应用程序中未显示的图像(使用Image .xcassets)

解决了!我尝试了很多。问题是发射图像在模拟器中显示而在实际设备中没有显示。我有一个UIImageView的故事板。奇怪的是,我最近添加的那些旧图片,和图片,都起作用了。首先,我认为这是资产的问题。不。然后我检查了颜色配置文件,并对不同的配置文件做了很多尝试:左工作图像,右不工作。没有帮助。

Then i started google and found this thread

然后我开始谷歌,找到了这个线程。

Main solutions from here:

主要解决方案从这里:

1) Didn't helped for me.

我帮不上忙。

Change image property of my launch image using Preview app: [ Tools --> Assign Profile... --> ColorSync Profile: <> ]

使用Preview app改变我的发射图像的图像属性:[Tools—> Assign Profile…]——> ColorSync配置文件:<>]

2) Helped

2)帮助

Even deleting the app and re-installing from XCode doesn't work. However, changing the bundle ID does work. With no other changes, the existing bundle ID shows no images, but the new bundle ID shows them all correctly. I'm doing that as a temporary work-around, since a previous post in this thread suggests that installing the builds via TestFlight doesn't encounter the problem.

甚至删除应用程序并从XCode重新安装都不行。但是,更改bundle ID确实有效。在没有其他更改的情况下,现有的bundle ID不会显示图像,但是新的bundle ID会正确地显示它们。我将其作为一个临时解决方案,因为这个线程中的前一篇文章建议通过TestFlight安装构建不会遇到这个问题。

3)

3)

I did three things (the first two on their own didn't do it, but may have assisted the third which did work)
1) Copied all of the images to the root directory (same location as xcode puts the images)
2) Created a folder in Images.xcassets and put the images in there.
3) The images in the launchScreen.xib were originally called imageName.png. This was changed to just imageName (remove the file extension.

我做了三件事(前两件事自己没有做,但可能帮助了第三件事做了)1)将所有的图像复制到根目录(与xcode放置图像的位置相同)2)在图像中创建一个文件夹。xcassets并将图像放在其中。3)launchScreen中的图像。xib最初被称为imageName.png。这被更改为仅imageName(删除文件扩展名)。

After the third thing the images appeared. I don't know if either of the first two steps are required, but hopefully it will help someone.

第三件事之后,图像出现了。我不知道是否需要前两步中的任何一步,但希望它能帮助某些人。

4) Helps but old and rude

4)帮助别人但又老又粗鲁

Taking the images out of the asset catalog fixed the problem for me. I just added the @1x, @2x, and @3x image used on my launch screen to the project the old way and it seems to be working fine. Trying to confirm it through TestFlight now, but iTunes Connect isn't behaving at the moment.

从资产目录中取出图像为我解决了这个问题。我刚刚添加了在我的启动屏幕上使用的@1x、@2x和@3x图像到项目中。试图通过TestFlight来确认,但是iTunes Connect现在不正常。

I thought this is an iPhone cash problem. So you don't need to warn about it thus the image will show when installing with testFlight. After this conclusion i did next and that worked:

我以为这是iPhone的现金问题。因此,您无需对它发出警告,因此在安装testFlight时映像将显示出来。在这个结论之后,我做了下一步,这是可行的:

1) Uninstall app
2) Reboot phone
3) Build app to the phone

1)卸载app 2)重启手机3)构建app到手机。

#8


0  

Close the simulator & open it again worked for me

关闭模拟器,再打开它为我工作。

#1


50  

I had this problem. I tested on simulator. I left the "Launch screen file" blank and removed the line about the "launch screen file" inside the plist. I restarted Xcode. Nothing. In my case in was not black it was white. Xcode 7 target ios 9.

我有这个问题。我在模拟器测试。我将“启动屏幕文件”留空,并删除了plist中有关“启动屏幕文件”的行。我重新启动Xcode。什么都没有。我的箱子里不是黑色的,是白色的。Xcode 7针对ios 9。

i read this one as well: Launch Image does not show up in my iOS App

我也读过这个:在我的iOS应用中没有显示启动图像

The launch image only showed up when i deleted the app from the simulator and run the app again.

只有当我从模拟器中删除应用程序并再次运行应用程序时,才会出现启动图像。

#2


37  

I finally figured it out!

我终于明白了!

So, in your project settings, go to the section that says: App Icons and Launch Images

所以,在你的项目设置中,转到“应用图标”一栏,启动图片

Remove the information found in Launch Screen File if you do not want to use .xib file.

如果不想使用.xib文件,请删除启动屏幕文件中找到的信息。

Then, in Launch Image Source, Choose to migrate and if you have already created your LaunchImage file and added the images to it. Then click the asset catalog that shows up. The name of the one that contains your Launch Images.

然后,在启动映像源代码中,选择迁移,如果您已经创建了LaunchImage文件并将映像添加到该文件中。然后单击出现的资产目录。包含你的发射图像的那个的名字。

This will create a new Launch-Image2 in your image set. To use the one you already have created, click the drop-down menu next to Launch Image Source. And you should see your other Launch Image set. Choose it. Then re-build your application and run it. You should see your Launch Image. =)

这将在您的映像集中创建一个新的Launch- image2。要使用您已经创建的那个,请单击next启动图像源的下拉菜单。你应该看到你的另一个发射图像集,选择它。然后重新构建应用程序并运行它。你应该看到你的发射图像。=)

Hope this helps!

希望这可以帮助!

Note: it won't delete your images that you already have in the asset catalog. It will just create a new LaunchImage asset set.

注意:它不会删除资产目录中已有的映像。它将创建一个新的LaunchImage资产集。

Reference: https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/chapters/StoringAppIconsandLaunchImagesinanAssetCatalog.html

参考:https://developer.apple.com/library/ios/recipes/xcode_help chapters/storingappiconsandlaunchimagesinanassetcatalog.html——image_catalog - 1.0 /

#3


23  

This is too important !

这太重要了!

should be empty ! Launch Screen File

应该是空的!启动屏幕文件

启动iOS应用程序中未显示的图像(使用Image .xcassets)

#4


9  

  • Make sure your images are accurate size according to Apple guidelines.
  • 根据苹果的指导方针,确保你的图片尺寸准确。
  • Make sure, You will select only one option , either launch screen file or Launch Image Source. You can find these two options in Project build settings -> General
  • 确保您将只选择一个选项,要么启动屏幕文件,要么启动图像源。您可以在项目构建设置中找到这两个选项——> General

Clean and build

清洁和构建

My suggestion to you is to select Launch Image Source as Image.Assets. Create splash image assets there in Image.assests folder. Must Clear the text in Launch screen file.

我的建议是选择Launch Image Source as Image. assets。在图像中创建溅出的图像资产。资产近文件夹。必须清除启动屏幕文件中的文本。

Reference image for right configuration: 启动iOS应用程序中未显示的图像(使用Image .xcassets)

正确配置参考图像:

#5


1  

Had a similar issue today. Tried to let xCode create automatically the Asset, but it was always unassigned.

今天也有类似的问题。尝试让xCode自动创建资产,但总是没有分配。

The solution was to create manually the Launch Image in the ImageAsset and assign the files for his respective resolution.

解决方案是在ImageAsset中手动创建发射映像,并为其各自的分辨率分配文件。

It looks like xCode created a different type of Launch Image asset, so it didn't recognized the asset (v8.3.2)

看起来xCode创建了不同类型的启动映像资产,所以它没有识别该资产(v8.3.2)

#6


0  

I just figured this out. My launch image was not showing up, I get a white screen when launching on a device (iPhone 6, 7+) or testFlight. Fix: Renamed "Landing_screen.png" to just "Landing_screen" removing .png part. https://*.com/a/43592662/3445278

我刚刚算出来了。我的发射图像没有显示出来,当我在一个设备(iPhone 6, 7+)或testFlight上发射时,我得到了一个白色的屏幕。解决办法:重新命名为“Landing_screen。png“只”到“Landing_screen”删除。png部分。https://*.com/a/43592662/3445278

#7


0  

Solved! I've tried a lot. The problem was that the launch image shows in simulator and didn't show in real device. I got a Storyboard with UIImageView in it. Strange was that old images worked, and images, that i did add recently not. First i thought that this is a problem with assets. No. Than i checked color profiles and did a lot of tries with different profiles: left-working image, right-not working. Didn't help. 启动iOS应用程序中未显示的图像(使用Image .xcassets)

解决了!我尝试了很多。问题是发射图像在模拟器中显示而在实际设备中没有显示。我有一个UIImageView的故事板。奇怪的是,我最近添加的那些旧图片,和图片,都起作用了。首先,我认为这是资产的问题。不。然后我检查了颜色配置文件,并对不同的配置文件做了很多尝试:左工作图像,右不工作。没有帮助。

Then i started google and found this thread

然后我开始谷歌,找到了这个线程。

Main solutions from here:

主要解决方案从这里:

1) Didn't helped for me.

我帮不上忙。

Change image property of my launch image using Preview app: [ Tools --> Assign Profile... --> ColorSync Profile: <> ]

使用Preview app改变我的发射图像的图像属性:[Tools—> Assign Profile…]——> ColorSync配置文件:<>]

2) Helped

2)帮助

Even deleting the app and re-installing from XCode doesn't work. However, changing the bundle ID does work. With no other changes, the existing bundle ID shows no images, but the new bundle ID shows them all correctly. I'm doing that as a temporary work-around, since a previous post in this thread suggests that installing the builds via TestFlight doesn't encounter the problem.

甚至删除应用程序并从XCode重新安装都不行。但是,更改bundle ID确实有效。在没有其他更改的情况下,现有的bundle ID不会显示图像,但是新的bundle ID会正确地显示它们。我将其作为一个临时解决方案,因为这个线程中的前一篇文章建议通过TestFlight安装构建不会遇到这个问题。

3)

3)

I did three things (the first two on their own didn't do it, but may have assisted the third which did work)
1) Copied all of the images to the root directory (same location as xcode puts the images)
2) Created a folder in Images.xcassets and put the images in there.
3) The images in the launchScreen.xib were originally called imageName.png. This was changed to just imageName (remove the file extension.

我做了三件事(前两件事自己没有做,但可能帮助了第三件事做了)1)将所有的图像复制到根目录(与xcode放置图像的位置相同)2)在图像中创建一个文件夹。xcassets并将图像放在其中。3)launchScreen中的图像。xib最初被称为imageName.png。这被更改为仅imageName(删除文件扩展名)。

After the third thing the images appeared. I don't know if either of the first two steps are required, but hopefully it will help someone.

第三件事之后,图像出现了。我不知道是否需要前两步中的任何一步,但希望它能帮助某些人。

4) Helps but old and rude

4)帮助别人但又老又粗鲁

Taking the images out of the asset catalog fixed the problem for me. I just added the @1x, @2x, and @3x image used on my launch screen to the project the old way and it seems to be working fine. Trying to confirm it through TestFlight now, but iTunes Connect isn't behaving at the moment.

从资产目录中取出图像为我解决了这个问题。我刚刚添加了在我的启动屏幕上使用的@1x、@2x和@3x图像到项目中。试图通过TestFlight来确认,但是iTunes Connect现在不正常。

I thought this is an iPhone cash problem. So you don't need to warn about it thus the image will show when installing with testFlight. After this conclusion i did next and that worked:

我以为这是iPhone的现金问题。因此,您无需对它发出警告,因此在安装testFlight时映像将显示出来。在这个结论之后,我做了下一步,这是可行的:

1) Uninstall app
2) Reboot phone
3) Build app to the phone

1)卸载app 2)重启手机3)构建app到手机。

#8


0  

Close the simulator & open it again worked for me

关闭模拟器,再打开它为我工作。