更新时间:2022-06-23 06:04:07
确保self订阅 UITextFieldDelegate
并初始化inputText:
Ensure "self" subscribes to UITextFieldDelegate
and initialise inputText with:
self.inputText.delegate = self;
将以下方法添加到self:
Add the following method to "self":
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == self.inputText) {
[textField resignFirstResponder];
return NO;
}
return YES;
}
或者在Swift中:
func textFieldShouldReturn(textField: UITextField) -> Bool {
if textField == inputText {
textField.resignFirstResponder()
return false
}
return true
}