I have added a custom inputAccessoryView with a subclassed UITextView inside it.
When I click on on the inputAccessoryView, the keyboard pushes it up and the following 2 warnings appear:
API error: <_UIKBCompatInputView: 0x7f92815391b0; frame = (0 0; 0 0); layer = > returned 0 width, assuming UIViewNoIntrinsicMetric
API error: <_UIKBCompatInputView: 0x7f92815391b0; frame = (0 0; 0 0); layer = > returned 0 width, assuming UIViewNoIntrinsicMetric
When I move the empty collectionView on the view controller, the keyboard descends as the inputAccessoryView moves back to the bottom of the screen and then 2 more warnings are displayed:
[View] First responder warning: 'TextInputView: 0x7f9282847000; baseClass = UITextView; frame = (10 10; 354 27); text = ''; clipsToBounds = YES; gestureRecognizers = ; layer = ; contentOffset: {0, 3}; contentSize: {158.5, 30.5}; adjustedContentInset: {0, 0, 14, 0}>' rejected resignFirstResponder when being removed from hierarchy
-[UIWindow endDisablingInterfaceAutorotationAnimated:] called on > without matching -beginDisablingInterfaceAutorotation. Ignoring.
What is causing these warnings and how do I prevent them? I looked up similar questions here and none of them contain a clear answer.
As requested, the inputAccessoryView:
class BigInputBar: UIView, UITextViewDelegate {
// MARK: - Subviews
let separatorLine = SeparatorLine()
// View that contains everything
var backgroundView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
lazy var inputTextView: TextInputView = {
let textView = TextInputView()
textView.translatesAutoresizingMaskIntoConstraints = false
textView.backgroundColor = .clear
return textView
}()
var sendButton: UIButton = {
let button = UIButton(frame: .zero)
let image = UIImage.getImage(named: "chevron-right")
button.setImage(image, for: [])
button.addTarget(self, action: #selector(sendButtonTapped), for: .touchUpInside)
button.translatesAutoresizingMaskIntoConstraints = false
button.setBackgroundImage(image, for: .highlighted) //Fun develop only graphic
button.backgroundColor = .clear
button.isEnabled = false
return button
}()
@objc private func sendButtonTapped(){
print("Button Tapped")
}
// MARK: Properties
override var intrinsicContentSize: CGSize {
return CGSize(width: bounds.width, height: 60)
}
// MARK: - Init Methods
convenience init() {
self.init(frame: .zero)
}
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
func setup() {
autoresizingMask = [.flexibleHeight]
addSubview(backgroundView)
addSubview(separatorLine)
backgroundView.addSubview(sendButton)
backgroundView.addSubview(inputTextView)
setupConstraints()
inputTextView.delegate = self
}
private func setupConstraints() {
separatorLine.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 0).isActive = true
separatorLine.rightAnchor.constraint(equalTo: self.rightAnchor, constant: 0).isActive = true
separatorLine.topAnchor.constraint(equalTo: self.topAnchor, constant: 0).isActive = true
backgroundView.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 0).isActive = true
backgroundView.rightAnchor.constraint(equalTo: self.rightAnchor, constant: 0).isActive = true
backgroundView.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: 0).isActive = true
backgroundView.topAnchor.constraint(equalTo: separatorLine.bottomAnchor, constant: 0).isActive = true
sendButton.rightAnchor.constraint(equalTo: backgroundView.rightAnchor, constant: -10).isActive = true
sendButton.topAnchor.constraint(equalTo: backgroundView.topAnchor,constant: 10).isActive = true
sendButton.widthAnchor.constraint(equalToConstant: 30).isActive = true
sendButton.heightAnchor.constraint(equalToConstant: 30).isActive = true
let leftTextView = inputTextView.leftAnchor.constraint(equalTo: backgroundView.leftAnchor, constant: 10)
let rightTextView = inputTextView.rightAnchor.constraint(equalTo: sendButton.leftAnchor, constant: -10)
let bottomTextView = inputTextView.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor, constant: -20)
let topTextView = inputTextView.topAnchor.constraint(equalTo: backgroundView.topAnchor,constant: 10)
NSLayoutConstraint.activate([leftTextView, rightTextView, bottomTextView, topTextView])
}
}