views:

551

answers:

7

Hello I have create an application on iphone using objective-c.In this application i am just displaying different players images stored in one folder, which will be run perfectly on simulator. But when I deploy it on iphone it is not showing the images of the player.

for that the code is:

UIImageView *imageplayer = [[UIImageView alloc]initWithFrame: CGRectMake(imgx, imgy+45,135,150)];
imageplayer.image = [UIImage imageNamed:playerpng];

if(imageplayer.image == nil)
    [imageplayer setImage:[UIImage imageNamed:playerjpg]];

if(imageplayer.image == nil)
    [imageplayer setImage:[UIImage imageNamed:@"noimage.png"]];

[self.view addSubView:imageplayer];

Plz solve this query. Thanks in advance

+1  A: 

check name of image file. It must be "noimage.png" not Noimage.png or noimage.PNG

oxigen
No its the same, if it is so then it will also not display in simulator. Isn't it??
@jaynaiPhone: The default file-system configuration for Mac OS X is case insensitive.
dreamlax
A: 

Did you copy the image into the resource folder or just link it?

hanno
I have copied it in resourse folder
A: 

This happens to me sometimes. I once spent half a night trying to figure out what was wrong. In this end, this is what worked: open the image with an image editor and save it again. That's all. I'm using the free Acorn image editor to do this. Haven't tried it with Photoshop. (After all, it seems that Photoshop might be responsible for introducing the error in the first place, although that's far from sure.)

I don't know what causes the problem. I usually get it when I use png files that have been sent to me. Could be a simple file permissions problem, or some more subtle problem with the image format. I would be very interested in hearing the opinion of better-informed people.

In any case, if all else fails just try this: open the image with Acorn, save over the original file. Works for me.

Felixyz
+2  A: 

Sometimes xCode doesent update correctly the bundle, try cleaning and building again.

Juan Karam
Thanks Juan, I spent the morning trying to work out what the problem was. In the end a clean fixed it.
Liam
+1  A: 

Just to clarify, does the "noimage.png" display, or is the program loading a player image but failing to display it? Or is nothing loading.

These should easily be determined in debug mode.

A few additional things to check...

1) Just for testing, start out with PNG versions of the player files. This is the primary format on the iPhone and might eliminate a file format issue or other anomaly that the simulator is not sensitive to.

2) With regard to fixing in an image editor, specifically make sure that the image is set to a DPI of 72 pixels/inch. The iPhone and particularly Interface Builder are very sensitive to this being correct and will sometimes not display or will display a very blurred version of the image if incorrect.

3) Make sure the image(s) haven't been added multiple times (from different directories and/or to different group folders). We encountered a situation where we had inadvertently imported the same images at two different layers within the project hierarchy and this can cause unexpected behavior within the iPhone (selecting randomly or failing to select).

4) Make sure the Get Info -> Targets has your particular target checked. The simulator may still see the image but it will not get deployed to the iPhone.

5) Make sure you can view the image within XCode and that it looks correct.

Barney

Barney Mattox
A: 

I have a very similar problem, I have images in my resources that I am displaying as .imageView.image in a UITableViewCell. Works perfect on the simulator but the image is not shown in the iphone.

I tried all the recommendations from Sir Lord and Barney without finding a solution. Is there anything else that could be tried?

Thanks