开发者

Change image of UIImageView on button click in iPhone program

开发者 https://www.devze.com 2023-01-09 08:28 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消