2

I had images starting with capital letters, I needed to change first letter of images manually on bundle , after doing that device can not show SOME of the images are not displayed while some of the images are displayed.

Such as: C_120x120@2x.png to c_120x120@2x.png

I get an array of letters

legend (
    g
)

and display them with

if ([testArray count]==1) {
            NSString *legendName=[NSString stringWithFormat:@"%@_120x120@2x.png",[testArray objectAtIndex:0]];
            UIImage *trackImage = [UIImage imageNamed:legendName];
            cell.imageView.image= trackImage;
            }

NSLOG:

track image string g_120x120@2x.png
track image (null)

In Bundle:

enter image description here

In finder project folder:

enter image description here

What I tried:

1) checked the case like above it looks like file names are correct;
2) deleted the images, changed the names before I add them to project.
3) delete the app on device , reinstalled it.
4) changed setting "Compress PNG Files" to NO

after doing everything above if I call C_120x120@2x.png in image it is displayed while c_120x120@2x.png is not displayed.

How can I solve this?

SpaceDust__
  • 4,844
  • 4
  • 43
  • 82
  • Have you just changed the Name or did you edit them in Photoshop or something? Maybe you accidentally changed the ColorSpace to CMYK or something like that. – xapslock Apr 16 '13 at 15:17

3 Answers3

2

Try cleaning your project - Shift + Apple + K.

Try removing @2x and the file extension .png:

NSString *legendName=[NSString stringWithFormat:@"%@_120x120",[testArray objectAtIndex:0]];

It'll detect whether to use the @2x based on the device being used.

Also be sure that they're added to your bundle. Click on the image, and in the inspector look under 'Target Membership'. Make sure the appropriate target is checked. (see https://stackoverflow.com/a/10998746/1710611 for screenshot)

Community
  • 1
  • 1
rog
  • 5,351
  • 5
  • 33
  • 40
  • `Shift + Apple + K` solved the problem, so whatsup with cleaning? what does it exactly do? – SpaceDust__ Apr 16 '13 at 15:45
  • `"clean: Removes all the product files, as well as any object files (.o files) or other intermediate files created during the build process."` Changing the case of the filename must've messed something up. Glad its working for you now. – rog Apr 16 '13 at 15:46
0

Make sure that the images are located in your "Copy Bundle Resources" section, it can be found in your project settings, select your target, and then it's under "Build Phases"

user352891
  • 1,181
  • 1
  • 8
  • 14
0

One of those PNGs was JPG and you just change the .jpg extension to .png

Good Luck

Mustafa Ibrahim
  • 1,110
  • 1
  • 9
  • 17
  • thanks for the input but this is not the case, I havent changed any extension, they were all ready png files. Besides 5 out of 8 images had problem not just one. – SpaceDust__ Apr 16 '13 at 16:30