UIImage* img = [UIImage imageNamed:@"girl1.jpg"]; imgView.image = img;
// // ViewController.h // // Created by Weerachai on 10/28/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController { IBOutlet UIImageView *imgView; } - (IBAction)btnImg1:(id)sender; - (IBAction)btnImg2:(id)sender; - (IBAction)btnImg3:(id)sender; - (IBAction)btnImg4:(id)sender; @end
// // ViewController.m // // Created by Weerachai on 10/28/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)dealloc { [imgView release]; [super dealloc]; } - (IBAction)btnImg1:(id)sender { UIImage* img = [UIImage imageNamed:@"girl1.jpg"]; imgView.image = img; } - (IBAction)btnImg2:(id)sender { UIImage* img = [UIImage imageNamed:@"girl2.jpg"]; imgView.image = img; } - (IBAction)btnImg3:(id)sender { UIImage* img = [UIImage imageNamed:@"girl3.jpg"]; imgView.image = img; } - (IBAction)btnImg4:(id)sender { UIImage* img = [UIImage imageNamed:@"girl4.jpg"]; imgView.image = img; } @end
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท