简体   繁体   English

Xcode 7无法以编程方式从称为“品牌资产”的图像集中访问启动图像

[英]Xcode 7 unable to access launch image programmatically from the set of images called “Brand Assets”

I just just migrated my launch images to assets with Xcode 7. My app was not using assets before. 我只是使用Xcode 7将启动映像迁移到资产中。我的应用以前未使用资产。 Xcode created an image catalog with AppIcon set an another set called "Brand Assets" with all my default images and that work just great. Xcode使用AppIcon创建了一个图像目录,并设置了另一个名为“ Brand Assets”的集合,其中包含我的所有默认图像,并且效果很好。 But, now I want to access the launch image programmaticaly. 但是,现在我想以编程方式访问启动映像。

I tried [UIImage imageNamed:@"Brand Assets"] and it does not work 我尝试了[UIImage imageNamed:@"Brand Assets"] ,但它不起作用

And here is what xcode generated as images 这是Xcode作为图像生成的内容

/var/mobile/Containers/Bundle/Application/.../my.app/Brand Assets-700-568h@2x.png, /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 Assets-700@2x.png, / var / mobile /容器/捆绑/应用程序/.../my.app/Brand Assets-700-568h @ 2x.png,/ var / mobile /容器/捆绑/应用程序/.../my.app/品牌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 Assets-700@2x.png,

I guess I can use [UIImage imageNamed:@"Brand Assets-700@2x.png"] for iPhone or the other generated names for iPad Portrait or Landscape 我想我可以为iPhone使用[UIImage imageNamed:@“ Brand Assets-700@2x.png”]或为iPad Portrait或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 注意:我的应用程序支持ios7

Thanks 谢谢

You need to use the open the Assets.xcassets to open the xcode assets & then you can use the name as follows: 您需要使用打开的Assets.xcassets来打开xcode资产,然后可以使用如下名称:

在此处输入图片说明

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: 从“项目”导航器中选择Assets.xcasssets,然后将显示已添加的所有资产,因此在下面的示例中,您可以按以下方式使用资产:

[UIImage imageNamed:@"report"]

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

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