@interface ViewController : UIViewController { IBOutlet UITextField *txtName; // for Text Field (Textbox) IBOutlet UILabel *lblResponse; // for Label } - (IBAction)Hello:(id)sender; // for Button Event
- (IBAction)Hello:(id)sender { //lblResponse.text = txtName.text; //[lblResponse setText:[txtName text]]; NSString *hello = @"สวัสดีครับคุณ "; NSString *name = txtName.text; NSString *message; message = [hello stringByAppendingString:name]; lblResponse.text = message; }
#import <UIKit/UIKit.h> @interface ViewController : UIViewController { IBOutlet UITextField *txtName; // for Text Field (Textbox) IBOutlet UILabel *lblResponse; // for Label } - (IBAction)Hello:(id)sender; // for Button Event @end
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (IBAction)Hello:(id)sender { //lblResponse.text = txtName.text; //[lblResponse setText:[txtName text]]; NSString *hello = @"สวัสดีครับคุณ "; NSString *name = txtName.text; NSString *message; message = [hello stringByAppendingString:name]; lblResponse.text = message; } - (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. } @end
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท