这对我有用:
import UIKitclass ViewController: UIViewController, UITextViewDelegate { @IBOutlet weak var textView: UITextView! override func viewDidLoad() { super.viewDidLoad() textView.delegate = self } func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { if(text == "n") { textView.resignFirstResponder() return false } return true } func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool { if(text == "n") { textView.resignFirstResponder() return false } return true }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)