UITextView in custom inputaccessoryView not resigning first responder status
I have a chat application that implements a floating text input field (similar to the iOS Messages app) as the inputAccessoryView
of my ChatViewController
(see Apple's documentation).
class ChatViewController: UIViewController {
override var inputAccessoryView: UIView? {
return chatInputView
}
override var canBecomeFirstResponder: Bool {
return true
}
...
My ChatViewController
has a ChatTableViewController
child view controller, which has cells containing UITextField
s whose text content is editable. The issue I'm running into is that when the user taps on a cell's UITextField
, the inputAccessoryView
's UITextView
refuses to resign first responder status, which prevents the content in the UITableViewCell
from being edited. The following warning is logged in the console:
First responder warning: '<UITextView: 0x7fc041041c00;
frame = ...' rejected resignFirstResponder when being removed from hierarchy
I've tried calling resignFirstResponder
and endEditing
on the UIInputView
and UITextView
directly with no success. I don't want the ChatViewController
to resign first responder status as that would cause the inputAccessoryView
to disappear.
Edit: I also receive the warning when dismissing the keyboard interactively (instead of tapping on the UITableViewCell
's UITextField
.
Could you please check the following:
If UITextView
is removed from super view:
UITextView
being removed from the view hierarchy ? resignFirstResponder
before removing it from the super view. If UITextView
subclass is being used:
UITextView
, if so have you implemented canResignFirstResponder
to return false
. true
instead. 上一篇: 用Maven执行Ant任务