custom inputAccessoryView as UIView from nib giving error: returned 0 width, assuming UIViewNoIntrinsicMetric : <p>I am using an inputAccessoryView which is loaded from a nib using the following UIView subclass:</p>

<pre><code>class CustomInputAccessoryView: UIView {

    @IBOutlet var containerView: UIView!
    @IBOutlet var contentView: UIView!
    @IBOutlet weak var button1: UIButton!
    @IBOutlet weak var button2: UIButton!
    @IBOutlet weak var textView: UITextView!        

    override var intrinsicContentSize: CGSize {
        return CGSize.zero
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupInputAccessoryView()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupInputAccessoryView()
    }

    func setupInputAccessoryView() {
        self.translatesAutoresizingMaskIntoConstraints = false
        Bundle.main.loadNibNamed("CustomInputAccessoryView", owner: self, options: nil)
        addSubview(containerView)
        containerView.frame = self.bounds
    }

}
</code></pre>

<p>I assign the view to the inputAccessoryView and set it up just by the following:</p>

<pre><code>var customInputAccessoryView = CustomInputAccessoryView()
</code></pre>

<p>The inputAccessoryView loads properly and displays correctly.  The problem is when I press inside the textView of the inputAccessoryView and the keyboard displays, I get the following error:</p>

<pre><code>&lt;_UIKBCompatInputView: ...; frame = (0 0; 0 0); layer = &lt;CALayer: ...&gt;&gt; returned 0 width, assuming UIViewNoIntrinsicMetric
</code></pre>

<p>I have two files, a .swift file which is the subclass of UIView displayed above and the nib file by the same name.  In the file owner of the nib I select the sub class (CustomInputAccessoryView) and wire up the outlets.</p>

<p>I don't really know what is happening other than maybe the input accessory view automatically resizing to zero frame whenever the keyboard is displayed before going to the correct size.  If so I'm assuming I need to change some AutoLayout priorities but what I have tried is not working.  The only hard width constraints are the buttons which have fixed widths.</p>

<p>The inputAccessoryView width should always be the width of the window it is displayed in.</p>
