Tono Nam
Tono Nam

Reputation: 36050

not able to change image in UIImageView control

This seems to me as a bug because I have changed images with:

someImage.image = [UIImage imageNamed:@"anotherImage.png"];

and I have never had a problem. so let me show you what I have:

I have placed an UIImageView:

enter image description here

note that imgObjetivos is conected to this UIImageView.

I have a method that get's called when clicking the following button: enter image description here

and the method contains:

enter image description here

as you can see I just want to change the current image with:

enter image description here

so when I run the application in the simulator everything looks great:

enter image description here

and when I press the button the image changes successfully:

enter image description here

Now why is it that when I run the application on my iPad the image does not change!? when I press the button the image disappears instead of getting a new image like in the simulator. I just learned objective-c and I am starting to dislike it. What am I doing wrong?


EDIT

I found a solution I changed the name of the image and now it works: enter image description here

but this makes no sense. Which names works and which ones do not? I also have make sure that I don't have two images with the same name and that is not the case. when I have a few letters after the '_' underscore it does not work. This is really strange. I am starting to dislike objective-c :(

Upvotes: 1

Views: 530

Answers (3)

Tono Nam
Tono Nam

Reputation: 36050

I had to rename the image name to something else I don't understand why... I thought that the problem was because I previously deleted that image that contained the same name but that is not the case because I imported the image with a similar name to the solution and I had the same problem. for example the original name of the image was objetivosFoto_h.png and when I renamed to objetivosFoto_ho.png it still did not work but when I renamed to objetivosFoto_horizontal.png it worked.

Upvotes: 0

Robert Childan
Robert Childan

Reputation: 983

I would go with removing the image file from the project, clean the project and add the file back.

Upvotes: 0

user789327
user789327

Reputation:

I've had the same problem before. The problem is that the image that you're using to replace the previous image is corrupted or say is not in it's original format.

In my case, I downloaded images in the web which was .jpg format and renamed it as .png format which actually made it .png. so in short term, ipad does not support the functionality for converting image format by just renaming the extension. you have to have a proper converter or something.

Upvotes: 2

Related Questions