1 //当点击键盘return键的时候 2 - (BOOL)textFieldShouldReturn:(UITextField *)textField 3 { 4 [textField resignFirstResponder]; // 释放第一响应者 5 NSLog(@"%@",textField.text); 6 return YES; 7 }
1 // 触摸屏幕回收键盘 2 - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 3 { 4 [self.view endEditing:YES]; 5 }