tags:

views:

26

answers:

1

Hi Everyone,

Still a newbie here, forgive me. I'm trying to make a button that will change an Image thats located in the same view.

- (IBAction)myButton:(id)sender {  
    myUIImageView.image = [UIImage imageNamed:@"image.jpg"];
}

And I synthesize myUIImageView above this. I have also created it in the .h file:

- (IBAction)myButton;
@property(retain, nonatomic) IBOutlet UIImageView* myUIImageView;

I have created a button called myButton in IB. Connected it's Touch Up Inside event to File's Owner. I've connected to the UIImageView with File's Owner. Also, I have image.jpg inside my resources folder, however the image stays the same when I push the button. Nothing happens! The app loads fine with no errors, any advice would help,

Thanks!

+1  A: 

Put an NSLog statement inside of your IBAction to make sure that you have properly connected to the action. Also make sure that you have the same signature for your IBAction in your header file and implementation file. Right now one of them is

- (IBAction)myButton;

and the other is

- (IBAction)myButton:(id)sender

Make sure that they both have the same signature.

DHamrick
I made sure they were both the top one, - (IBAction)myButton; and I used NSLog(@"button pushed"); and it was printed to the console! So perhaps this tells me that its mapped correctly in IB, and that something inside my button code is not working properly
Pete Herbert Penito