Doug Molineux
Doug Molineux

Reputation: 12431

Getting UIImageView to Change its Image IPhone App

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!

Upvotes: 0

Views: 151

Answers (1)

DHamrick
DHamrick

Reputation: 8488

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.

Upvotes: 1

Related Questions