title: How to add a view inside an UITableView programmatically?
body: <p>While in the Interface Builder, it's pretty easy to add an <code>UIView</code> to an <code>UITable</code> and show it correctly, just drag and drop and it's done. But now that's gonna be optional, so it has to be placed programmatically.</p>
  
  <p>Here's how it looked like in the interface builder:
  <img src="https://i.stack.imgur.com/SmyRT.png" alt="How it looked like in the Interface Builder"></p>
  
  <p>When I added the new view as a subview, it showed on top of the <code>UITableView</code>-content, but the content should have some offset. I tried it with the following code:</p>
  
  <pre><code>self.scrollView.frame = CGRectMake(0, -140, self.scrollView.frame.size.width, self.scrollView.frame.size.height);
  [self.tableView addSubview:self.scrollView];
  [self.tableView setContentInset:UIEdgeInsetsMake(140,0,0,0)];
  [self.tableView setContentOffset:CGPointMake(0, -140) animated:NO];
  </code></pre>
  
  <p>That seemed to work, it shows correctly.. But when I scroll down, the section header stays at 140 pixels from the top. So I guess I'm using the wrong approach, but have absolutely no idea how to fix it. Could anyone give me a push in the right direction?</p>