Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JRuc33

macrumors newbie
Original poster
Jul 29, 2009
3
0
Code:
- (IBAction)touch_btnAdvice:(UIButton *)sender {
        UIImage	*aceC = [UIImage imageNamed: @"black.png"];
	[pPic10 setImage: aceC];
}

Basically, what I want to happen is when I press the button for the image to change. I have an image named "black.png" in my project, but the image won't change. Thanks in advance for the help. Don't know whats wrong with this code segment, but obviously something is wrong cuz the picture won't change.
 
Double check Interface Builder - make sure the action for "touch up inside" on the button is linked to that function. Double check the other outlets as well, but the touch up inside action should be the first place to look.

EDIT:
Throw this in your function. It may seem stupid and simple but its an easy way to see if a function is being called. I spent 10 minutes today banging my head with respect to a function not doing what it was supposed to, but it turned out I had called it after a return statement and it actually never got called.
Code:
NSLog(@"function called");
 
Yeah, I'm sure it gets called when I press the button because if I add a line of code like
Code:
[label1 setText: @"Hello World"];

The label will change.
 
If you're sure your action is being called, then the next thing to look at is to determine if your aceC UIImage is being properly setup. You are not getting any runtime errors or warnings around this? Are you certain that black.png is case-correct and has been copied to (not just linked to) your project? Also, how is pPic10 declared? Since we haven't seen that code, we can't be sure the issue doesn't involve that.
 
I'm new to this, and I may be off base, so take this with a grain of salt....but, don't you need to specify WHERE the image is so that the program can actually find it?
 
I think it's easier to do this:

Code:
myImage.image = [UIImage imageNamed:@"whatever.png"];

Personally, that's what I would use.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.