0

In my iOS project, I creat a xcasset named:PaoPaoImages.xcassets then I put all images into PaoPaoImages.xcassets.

And I have a xib file named:a.xib, I compile it into a.nib. Then I put a.nib into a bundle named:paopao.bundle.

So, now, my images in PaoPaoImages.xcassets , and my nib in PaoPao.bundle. And the nib reference the images. Then, I run my project, the nib cannot show the images.

I'm stumped... any advice?

PanLin
  • 43
  • 1
  • 7
  • Does this have anything to do with coding? – Evan Carslake Jan 06 '16 at 15:52
  • dont do anything with coding. I mean that : my images in PaoPaoImages.xcassets , and my nib in PaoPao.bundle. And the nib reference the images. Now, I run my project, the nib cannot show the images. Thank you very much. – PanLin Jan 07 '16 at 03:50

2 Answers2

1

In order to access the image from the Asset Catalog, you only need to access the name of the asset group without any extensions.

So, if you add an image named @"my-button@2x.png" to the Asset Catalog, it will create an asset group called my-button.

Now, all you have to do is access the image like so:

In coding use following line

[UIImage imageNamed:@"my-button"];

instead of

[UIImage imageNamed:@"my-button.png"];

Also, you can edit the asset group by renaming it (without renaming the images) or changing it's individual components. This will allow you to follow easier naming conventions as well as show completely different assets between different UIScreen scales without any scale checks.

In order to incorporate images for different device sizes, you may need to toggle it under the "Devices" subheading in the Asset Catalog Group's options. Here is an example of that toggle (available by right clicking the group).

  • Thank you very much! But,I mean that : my images in PaoPaoImages.xcassets , and my nib in PaoPao.bundle. And the nib reference the images. Now, I run my project, the nib cannot show the images. – PanLin Jan 07 '16 at 03:49
0

==> check here code try it:-

NSBundle *myImageBundle=[NSBundle bundleWithPath: myBundlePath];

NSArray *ImageURLs=[myImageBundleURLsForResourcesWithExtension:@"png" subdirectory:nil];

NSLog(@"imageURLS: %@",ImageURLs);

=>here refrence more try it:-

Access Asset Catalog programmatically

Load image from bundle with IOS

Community
  • 1
  • 1
Akash
  • 461
  • 2
  • 14
  • Sorry,I mean that : my images in PaoPaoImages.xcassets , and my nib in PaoPao.bundle. And the nib reference the images. Now, I run my project, the nib cannot show the images. – PanLin Jan 07 '16 at 03:46