title: iOS - resize UITableView height programmatically
body: <p>I'm having a problem trying to programmatically resize the height of a <code>UITableView</code> hosted within a <code>UIViewController</code>, using iOS5 and Storyboards.  The VC displays a master/detail record style with the <code>UITableView</code> displaying the detail records.  Depending on the type of master record shown, a set of buttons may be needed at the foot of the screen.  If the buttons are not needed then I want the <code>UITableView</code> to extend it's height to take advantage of the space available.  I'm using the following code :</p>
  
  <pre><code>CGRect tableFrame = [tableListView frame];
  if (blnApprovalRec == YES)
      tableFrame.size.height = 127;
  else
      tableFrame.size.height = 170;
  [tableListView setFrame:tableFrame];
  </code></pre>
  
  <p>This code is called whenever the master record changes, including when the screen first loads in <code>viewDidLoad</code>.  The problem is that when the VC loads, the <code>UITableView</code> doesn't paint using the size specified - it just paints with the default size from IB.  Once the user changes the master record so the table is reloaded then everything works fine and the size changes as required.  I've tried forcing a repaint using <code>setNeedsDisplay</code>, <code>setNeedsLayout</code> and <code>reloadData</code> but none of these worked.</p>