Two Laptop Bag*
The moose likes iOS and the fly likes IOS development, problems with setting uibutton image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » iOS
Bookmark "IOS development, problems with setting uibutton image" Watch "IOS development, problems with setting uibutton image" New topic
Author

IOS development, problems with setting uibutton image

Susana Brown
Greenhorn

Joined: Jul 10, 2012
Posts: 2
Can any one tell me what is wrong with this code?

Only the else part is not working, if I have an image for the note, every thing is working just perfect, but when i am trying to show the "no_image" image, i just don't see it (there is not error). Looks like a "nil", but the image is in the project, for sure. i am using the same image in other places and other methods and it is working over there. just in the UIButton not working.

//setting the note header data
if (note.imageThumb) {
[photoButton setImage:note.imageThumb forState:UIControlStateNormal];
} else {
[photoButton setImage:[UIImage imageNamed:@"no_image.png"] forState:UIControlStateNormal];
}


Savvycom software
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well, it has been a little while, but.

1) Are you sure the image is added correctly to the project, so it knows where it is located automatically?
2) Have you tried instantiating the Image on a separate line so you an better debug the root cause.
Is it [UIImage imageNamed:@"no_image.png"]
or
forState:UIControlStateNormal];
or
[photoButton setImage:

The last two I probably would look at together. But because you put it all in one line makes it tougher to figure out what is wrong, or what is really causing the problem.

Is the "@" supposed to be inside the quotes in the code???

Also we have a code button for posting code to this forum so that it keeps its indentation and makes it more readable. Now you just have 5 lines so no big deal, but for the future posts.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Susana Brown
Greenhorn

Joined: Jul 10, 2012
Posts: 2
I did check what you suggested. It run well now. Thank you!
julia arvil
Greenhorn

Joined: Jan 07, 2013
Posts: 1
i don't know why you can do it, but i can't. is it out of date or something


Bill sharing app for roommates and Rent Room Calculator
 
jQuery in Action, 2nd edition
 
subject: IOS development, problems with setting uibutton image
 
Similar Threads
Displaying image problem
FAILED BINDER TRANSACTION
Image Compression
How to create black buttons with white font?
setEnabled Not Working on iPhone