title: How to disable scrolling in UITableView table when the content fits on the screen
body: <p>I have a few (grouped style) tables in my iphone app (only on part of the screen and added with <code>Interface Builder</code> though, not subclassed from <code>UITableViewController</code>) that 80% of the time are small and will fit on the screen.  When the table fits on the screen, I'd like to disable scrolling, to make it a bit cleaner.  But if the table goes off the screen (when rows are later added to it), I'd like to enable scrolling again (because otherwise you can't see that content.)</p>
  
  <p>Is there a way to do this?  I can't seem to figure it out.  I do know to do: </p>
  
  <pre><code>tableView.scrollEnabled = NO;
  </code></pre>
  
  <p>but I'm not sure where, or if I have to calculate the table object size or something to get this to work. </p>
  
  <p><hr />
  <strong>Update</strong>:
  Here's the solution that finally worked for me:</p>
  
  <pre><code>if (table.contentSize.height &lt; table.frame.size.height) {
     table.scrollEnabled = NO;
   }
  else {
     table.scrollEnabled = YES;
   }
  </code></pre>
  
  <p>I run this code after calling <code>reloadData</code> on the table, and it calculates the right sizes and appears to work.</p>
  
  <p><code>table.frame.size.height</code> is the actual size of the object (you can see this in <code>Interface Builder</code>) displayed on the screen, whereas <code>table.contentSize.height</code> is the heights of: the header, the footer, and the height of every cell added together.</p>