title: How to achieve an advanced table view header
body: <p>I have a grouped <code>UITableView</code>. Now unlike the default table view header my header should be <em>next</em> to the individual cells:</p>
  
  <p>Standard:</p>
  
  <pre><code>[Header Cell]
  [Item 1]
  [Item 2]
  </code></pre>
  
  <p>What I need </p>
  
  <pre><code>+-------+----------------+
  |       |  Item 1a       |
  |  h1   +----------------+
  |       |  Item 1b       |
  + - - - +----------------+
  |          Item 1c       |
  +------------------------+
  |       |  Item 2a       |
  |  h2   +----------------+
  |       |  Item 2b       |
  +------------------------+
  |       |  Item 3a       |
  |  h3   +----------------+
  |       |  -placeholder- |
  +-------+----------------+
  </code></pre>
  
  <p>Some remarks:</p>
  
  <ul>
  <li>Group H1 has three items</li>
  <li>Group H2 has two items</li>
  <li>Group H3 has just one item (I have to insert a placeholder cell so that the header cell can have the full height of two item-cells</li>
  <li>When the user scrolls the list then the header should be pushed upwards that the two header-cells don't overlap.</li>
  </ul>
  
  <p>The challenge here is the height of the header cell:</p>
  
  <ul>
  <li>If I set the height to 0 and uncheck <code>clip subviews</code> then that header cell is shown but does not get pushed away at the correct position.</li>
  <li>If I set the height of the header cell to the visual height then there is an empty space of that height <em>across</em> the whole width of the table which I don't want... </li>
  </ul>
  
  <p><strong>Update 1:</strong> I just realized that apple uses such a list for the search (grouped by messages, mails, contacts, calenders etc.). So my question basically is how can I tweak <code>UITableView</code> in order to behave like the grouped search results... :-)</p>
  
  <p><a href="https://i.stack.imgur.com/fFz1E.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fFz1E.jpg" alt=""></a><br>
  <sub>(source: <a href="http://6.mshcdn.com/wp-content/uploads/2010/08/2photo.jpg" rel="nofollow noreferrer">mshcdn.com</a>)</sub>  </p>