[英]How to Stop Keyboard From Showing When UITextField is Tapped?
你可以这样-
YourTextView.inputView = UIView()
YourTextView.inputAccessoryView = UIView()
这不会打开键盘,但会允许光标闪烁。
尝试这样做:
extension YourController: UITextFieldDelegate {
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
// do some things
NotificationCenter.default.addObserver(self, selector: #selector(keyboardHidden),
name: NSNotification.Name.UIKeyboardWillShow, object: nil)
return false
}
@objc private func keyboardHidden() {
// disabled keyboard
yourTextField.resignFirstResponder()
}
}
@paulvs链接到Swift 3的答案是:
let tempView = UIView(frame: .zero)
yourTextField.inputView = tempView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.