title: InputAccessoryView docked at bottom
body: <p>I'm trying to achieve similar positioning behavior as the bottom text input bar in Apple's Messages app.</p>
  
  <p>I have tried many approaches, searched high and low and there are many similar questions but none have been satisfactory.</p>
  
  <p>To specify:</p>
  
  <ol>
  <li>There is a <code>UIToolbar</code> at the bottom of the view</li>
  <li>The toolbar is to follow the keyboard as the keyboard appears and disappears</li>
  <li>The toolbar should stay on top of the keyboard when the keyboard is visible</li>
  <li>When the keyboard is hidden, the toolbar stays ("docked") at the bottom of the view</li>
  </ol>
  
  <p><strong>The proposed solutions:</strong></p>
  
  <h2>Manually animate the toolbar in response to keyboard appearance notifications</h2>
  
  <p>This solution does not meet a special case of the second requirement (<em>the toolbar is to follow the keyboard as the keyboard appears and disappears</em>):</p>
  
  <ul>
  <li>In iOS 7, <code>UIScrollViewKeyboardDismissMode</code> was introduced. It enables an interactive gesture for dismissing the keyboard. As the the user pans past the top edge of the keyboard, the keyboard frame gradually follows. This solution does nothing to accomodate this behavior and just leaves the toolbar stranded at it's animated position.</li>
  </ul>
  
  <p>In addition, this solution also fails to fulfil a special case of the third requirement (<em>the toolbar should stay on top of the keyboard when the keyboard is visible</em>):</p>
  
  <ul>
  <li>Rotation. This solution calls for additional, annoyingly extraneous code (as we will see in the next proposed solution) to rotate the toolbar in response to device rotation.</li>
  </ul>
  
  <p>Another issue with this solution:</p>
  
  <ul>
  <li>Keyboard height. With this solution, the toolbar it is not assumed to be part of the height of the keyboard, so additional code must be written to support proper insetting of content.</li>
  </ul>
  
  <p><strong>Next proposed solution:</strong></p>
  
  <h2>Use <code>UIResponder</code>'s <code>inputAccessoryView</code></h2>
  
  <p>This solution seems to be the way Apple intended to support this kind of behavior, as it solves all the shortcomings of manually animating the toolbar. But this solution completely misses the fourth requirement (<em>when the keyboard is hidden, the toolbar stays ("docked") at the bottom of the view</em>).</p>
  
  <hr>
  
  <p>It seems the solution is to use <code>UIResponder</code>'s <code>inputAccessoryView</code>, but somehow making the <code>inputAccessoryView</code> not move below the view. I'm looking for clean code to accomplish this. There are elaborate, almost noble, attempts elsewhere, but as mentioned, they do not meet the requirements.</p>
  
  <p>In my particular case, I am looking to use <code>UINavigationController</code>'s toolbar which entails additional issues as this is not intended behavior for <code>UINavigationController</code>. No matter, I'm willing to introduce some hacky fixes to accomplish that.</p>