Reputation: 103
In my case, I am having two textview
one I placed into view another one within UIAlertController
. Here, I added done
and cancel
button on keyboard accessory
with actions. Now, how to create resign responder for both UITextView
?
@IBAction func doneClick(_ sender: Any) {
self.descriptionTextView.resignFirstResponder()
self.textView.resignFirstResponder() // Its making crash sometime
}
Upvotes: 0
Views: 36
Reputation: 100523
It appears that one of them is nil at some time , so You can do
self.view.endEditing(true)
Or make them optional like
self.descriptionTextView?.resignFirstResponder()
self.textView?.resignFirstResponder()
Upvotes: 1