0

I just just migrated my launch images to assets with Xcode 7. My app was not using assets before. Xcode created an image catalog with AppIcon set an another set called "Brand Assets" with all my default images and that work just great. But, now I want to access the launch image programmaticaly.

I tried [UIImage imageNamed:@"Brand Assets"] and it does not work

And here is what xcode generated as images

/var/mobile/Containers/Bundle/Application/.../my.app/Brand [email protected], /var/mobile/Containers/Bundle/Application/.../my.app/Brand Assets-700-Landscape@2x~ipad.png, /var/mobile/Containers/Bundle/Application/.../my.app/Brand Assets-700-Landscape~ipad.png, /var/mobile/Containers/Bundle/Application/.../my.app/Brand Assets-700-Portrait@2x~ipad.png, /var/mobile/Containers/Bundle/Application/.../my.app/Brand Assets-700-Portrait~ipad.png, /var/mobile/Containers/Bundle/Application/.../my.app/Brand [email protected],

I guess I can use [UIImage imageNamed:@"Brand [email protected]"] for iPhone or the other generated names for iPad Portrait or Landscape

Is there a more safe way to obtain the generated launch screen so I can use it in my code ?

Someone experimented this ?

Note: My app support ios7

Thanks

2
  • You need to specify the name of the image set, not the name of the asset. But you really shouldn't attempt to load a launch image using UIImage because the algorithm to load an image using imageNamed: doesn't match how launch image assets are setup. Commented Dec 18, 2015 at 0:16
  • I need to use launch image to add an activity indicator while my data is downloading, what can I do then ? Commented Dec 18, 2015 at 16:04

1 Answer 1

1

You need to use the open the Assets.xcassets to open the xcode assets & then you can use the name as follows:

enter image description here

Select the Assets.xcasssets from Project navigator,then all assets that you have added will be displayed, so in the example below you can use the asset as follows:

[UIImage imageNamed:@"report"] 
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for the answer
I have Images.xcasset and inside I have my "Brand Assets" with all the launch images so I did what you say and the image is not loaded, is there a special case with launch images?
No, it should have worked,can you upload your screen shot of assets & code sample?
My launch image is good but when I do [UIImage imageNamed:@"Brand Assets"] the image is not loaded Brand Assets it's the name that xcode gived to my launch images
I think I understand the issue: [UIImage imageNamed:@"image set"] work great for all image assets but for AppIcon and LaunchImage sets, it could not work as the naming convention is different as the generated images are not 1x 2x or 3x.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.