feat: make server search text field handle return key

This commit is contained in:
CMK 2021-06-04 18:42:22 +08:00
parent 3ab78f1134
commit 7115951f6b
1 changed files with 11 additions and 0 deletions

View File

@ -52,6 +52,7 @@ class PickServerSearchCell: UITableViewCell {
textField.clearButtonMode = .whileEditing
textField.autocapitalizationType = .none
textField.autocorrectionType = .no
textField.returnKeyType = .done
return textField
}()
@ -78,6 +79,7 @@ extension PickServerSearchCell {
backgroundColor = Asset.Colors.Background.systemGroupedBackground.color
searchTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)
searchTextField.delegate = self
contentView.addSubview(bgView)
contentView.addSubview(textFieldBgView)
@ -107,3 +109,12 @@ extension PickServerSearchCell {
delegate?.pickServerSearchCell(self, searchTextDidChange: textField.text)
}
}
// MARK: - UITextFieldDelegate
extension PickServerSearchCell: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return false
}
}