开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜