内容简介:翻译自:https://stackoverflow.com/questions/28280191/swift-dismiss-uitextview-keyboard
我很难在 swift
中解雇文本视图的键盘.
我能够用以下内容解雇文本字段
@IBAction func DismissKeyboard(sender: AnyObject)
{
self.resignFirstResponder()
}
但我不确定如何用文本视图来解决它
您必须将textview.delegate设置为self并使用shouldChangeTextInRange函数在按回车时重新签名.
func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {
if text == "\n" // Recognizes enter key in keyboard
{
textView.resignFirstResponder()
return false
}
return true
}
翻译自:https://stackoverflow.com/questions/28280191/swift-dismiss-uitextview-keyboard
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。