How do I use the Launch Images from an Asset Catalogue in the Launch Storyboard?
Asked Answered
K

3

11

I do need to support both storyboard-based launch screens and 'traditional' launch images in a project.

Adding a Launch Screen storyboard with an UIImageView pointing to the launch screen seemed like a straightforward way of doing so. Yet, Interface Builder cannot locate the launch image and cannot display it at all.

As all sizes differ also in content, will the storyboard even select the right image?

Reconstructing the images with size classes and constraints is not quite possible, so

TL;DR: How do use a Launch Storyboard that uses the corresponding images from the set of launch screen images?

Kolva answered 1/3, 2016 at 8:51 Comment(1)
Any solutions to that?Hype
G
5

I know this is an old question. Short answer is "you can't", but there is a workaround.

Here is how I do it:

Do not add the images you want to use to an asset catalog. Instead, add the images directly to your project and make sure you have them included in the target. You have to go back to the old "image.png", "[email protected]", "[email protected]" naming convention in order to supply different images for different screen sizes.

Hope that helps anyone who comes across this.

Adding images to target Set image to ImageView in LaunchScreen storyboard $$$

Gussie answered 9/2, 2018 at 1:36 Comment(1)
In case this helps with SEO, I tried several approaches to making the UIImageView use an image from a target-specific asset catalog. I opened the "contents.json" and pasted the file name into Interface Builder, the ImageView didn't load despite all the asset catalogs having the same image sizes and names (with different content). That failed, but using Jordan's method worked.Isodimorphism
J
0

In Assets.xcassets, click on + and select App Icons & Launch Images --> New iOS Launch Image. Drag & Drop your Launch Images with the mentioned sizes. Now in Project & targets List, select your Project & then General Tab. In App Icons & Launch Images, click on Launch Images Source & select your newly created source file.

Jerald answered 1/3, 2016 at 9:16 Comment(2)
Yeah, so much for the asset catalogue; that's working fine. I cannot reference it from the storyboard though.Kolva
That question wasn't how to setup the Launch Images with an Asset Catalog, but how to reference them in code (or storyboard)Administrate
B
0

In order to use Images.xassets images in your loading screen enter image description here you have to manually delete LaunchScreen.storyboard and set .xassets as an option in General tab of your main target. enter image description here

Also, there might be a bug with an empty launch screen, until you delete app from your simulator (or device) and reinstall it.

Blighter answered 17/9, 2019 at 10:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.