为 TextView 禁用键盘中的 Return 键
Disable Return key in keyboard for TextView
我需要禁用特定控制器键盘上的 Return 键,当用户在 TextView 中书写时,但我无法在网络上找到任何有效的解决方案(它们似乎适用于TextField 但不适用于 TextView)。
我怎样才能做到这一点?
谢谢。
你可以试试这个:
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
return text != "\n"
}
希望对您有所帮助!!
我需要禁用特定控制器键盘上的 Return 键,当用户在 TextView 中书写时,但我无法在网络上找到任何有效的解决方案(它们似乎适用于TextField 但不适用于 TextView)。 我怎样才能做到这一点? 谢谢。
你可以试试这个:
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
return text != "\n"
}
希望对您有所帮助!!