1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #import "ViewController.h"
@interface ViewController ()<UITextFieldDelegate> @property (weak, nonatomic) IBOutlet UITextField *userName; @property (weak, nonatomic) IBOutlet UITextField *passWord; @property (weak, nonatomic) IBOutlet UIButton *button;
@end
@implementation ViewController
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (IBAction)login:(UIButton *)button { NSLog(@"%@ %@",self.userName.text,self.passWord.text); }
- (BOOL)textFieldShouldReturn:(UITextField *)textField { if(textField==self.userName) { [self.passWord becomeFirstResponder]; }else if(textField==self.passWord) { [self login:self.button]; } return YES; } @end
|