Change image of UIImageView on button click in iPhone program
I want to change image in image viewer when I click a button. I know this que开发者_如何学Pythonstion basic but, I need an answer for this. Please reply
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.
精彩评论