This is only a warning and the app works fine but there might be a reason for this warning to be there.
I found similar issues on the web but no answers yet. first, the error:
[View] First responder warning: '; layer = ; contentOffset: {0, 0}; contentSize: {302, 20}; adjustedContentInset: {0, 0, 0, 0}>' rejected resignFirstResponder when being removed from hierarchy
The setup is a chatviewcontroller so it's a UITableView embedded inside a UIViewController that contains cells with text.
We are using the Dismiss Interactively keyboard function of the UIScrollView class to be able to dismiss the keyboard when we swipe down on the list of chat items.
We add an inputAccessory to the keyboard to be used as a text input area + send button.
In the UIViewController that contains the UITableView, we add the following UIResponder override to get the accessoryView.
override var inputAccessoryView: UIView {
return messageInputView
}
The problem is that we dismiss interactively the keyboard (so that it disappear from the screen), we get this warning. Any input, any help on the topic would be great!
You can ask the system to dismiss the keyboard by calling the resignFirstResponder method of your text field. Usually, you dismiss the keyboard in response to specific interactions. For example, you might dismiss the keyboard when the user taps the keyboard's return key.
If you have a UITextField and you want to hide the keyboard when the user is pressing the return key, use the textFieldShouldReturn function. Be sure you have set the textField. delegate = self in your viewDidLoad() function.
If you want that text control to stop waiting for input – which in turn dismisses the keyboard – you should call its resignFirstResponder() method, which passes the first responder baton to the next waiting component.
I just found out that if you override the viewWillTransition
function and call collectionView.collectionViewLayout.invalidateLayout()
in it, it will fix the problem!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With