指定文本框代理
- (void)viewDidLoad {
[ super viewDidLoad];
txt.delegate = self;
}
按回車隱藏鍵盤
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
點擊view其它地方隱藏鍵盤
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[txt resignFirstResponder];
}
//觸摸事件
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;