[英]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.