如何使用返回鍵關閉 UITextView 的鍵盤? - How to dismiss keyboard for UITextView with return key?

問題:

Want to improve this post? 想改進這篇文章嗎? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. 提供此問題的詳細答案,包括引文和解釋爲什麼您的答案是正確的。 Answers without enough detail may be edited or deleted. 沒有足夠詳細信息的答案可能會被編輯或刪除。

In IB's library, the introduction tells us that when the return key is pressed, the keyboard for UITextView will disappear.在IB的庫中,介紹告訴我們,當按下回車鍵時, UITextView的鍵盤就會消失。 But actually the return key can only act as '\\n'.但實際上返回鍵只能充當'\\n'。

I can add a button and use [txtView resignFirstResponder] to hide the keyboard.我可以添加一個按鈕並使用[txtView resignFirstResponder]來隱藏鍵盤。

But is there a way to add the action for the return key in keyboard so that I needn't add UIButton ?但是有沒有辦法在鍵盤中添加返回鍵的動作,這樣我就不需要添加UIButton


解決方案:

參考一: https://en.stackoom.com/question/2x4s
參考二: https://stackoom.com/question/2x4s
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章