Reputation: 1921
I want to change image in image viewer when I click a button. I know this question basic but, I need an answer for this. Please reply
Upvotes: 0
Views: 953
Reputation: 9593
First, implement the following method in a MyViewController.m (also, add method signature to MyViewController.h file):
MyViewController.m:
- (IBAction)handleButtonClick:(id)sender {
imageView.image = [UIImage imageNamed:@"blah.png"];
}
MyViewController.h:
{
IBOutlet UIImageView *imageView;
}
- (IBAction)handleButtonClick:(id)sender;
Then attach handleButtonClick action to button's Touch up inside event and imageView outlet to your image view in Interface builder.
Voila.
Upvotes: 1