Advertisement
Avatarr

iPhone app

Dec 6th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // controller.m
  2.  
  3.  
  4.  
  5. @implementation HelloAgainViewController
  6.  
  7. -(IBAction) sayHello{
  8.     NSString * out = [NSString stringWithFormat:@"Hello,%@",[txtName text]]; // settext to var
  9.    
  10.     [label setText:out]; // SET STRIMG TO LABEL FORM NSSTRING
  11.     [txtName resignFirstResponder];// hide keybord
  12. }
  13.  
  14.  
  15. - (void)dealloc
  16. {
  17.     [super dealloc];
  18. }
  19.  
  20. - (void)didReceiveMemoryWarning
  21. {
  22.     // Releases the view if it doesn't have a superview.
  23.     [super didReceiveMemoryWarning];
  24.    
  25.     // Release any cached data, images, etc that aren't in use.
  26. }
  27.  
  28. #pragma mark - View lifecycle
  29.  
  30.  
  31. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  32. - (void)viewDidLoad
  33. {
  34.     [super viewDidLoad];
  35.     [label setText:@""];
  36.     [txtName setPlaceholder:@"Type your name"]; //ข้อความนำ
  37.  
  38. ----------------------------------------------
  39.  
  40. // controller.h
  41.  
  42. #import <UIKit/UIKit.h>
  43.  
  44. @interface HelloAgainViewController : UIViewController {
  45.     IBOutlet UILabel * label;
  46.     IBOutlet UITextField * txtName;
  47.      
  48.    
  49. }
  50. -(IBAction) sayHello;
  51.  
  52. @end
  53.  
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement