title: 'UIViewControllerHierarchyInconsistency' thrown when using a UIViewController's view as UITextField's inputView
body: <p>I spent the day trying to figure out a crash on my app related with a textfield's inputView. I've tried making a test project to reproduce the crash. Here's what I have :</p>
  
  <pre><code>class ViewController: UIViewController {
  
    let keyboardVC = KeyboardViewController()
  
    override func viewDidLoad() {
      super.viewDidLoad()
  
      keyboardVC.view.backgroundColor = .blue
  
      let textField = UITextField()
      textField.inputView = keyboardVC.view
      textField.backgroundColor = .red
  
      view.addSubview(textField)
    }
  }
  </code></pre>
  
  <p>If I tap once on the textfield, everything works as expected, my blue view is displayed instead of the keyboard. But if I tap multiple times on the textField during the inputView animation, the app crashes with the following exception:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 
  'UIViewControllerHierarchyInconsistency', reason: 'child view 
  controller:&lt;Test.KeyboardViewController: 0x7ff53c008f20&gt; should have 
  parent view controller:&lt;UICompatibilityInputViewController: 
  0x7ff539403a40&gt; but requested parent is:&lt;UICompatibilityInputViewController: 0x7ff53940e330&gt;'
  </code></pre>
  
  <p>I am probably missing something obvious but I can't figure out what's is going on... Any help is appreciated :)</p>
  
  <p>Thanks!</p>