Removing extra separator lines for empty rows in UITableView

I discovered this by accident. It’s probably been there for a long time but I just noticed it now. Normally, if you have very few rows in your table, it would look like this:

Default row lines

Notice that I only have 2 rows. The other empty ones still have empty separator lines. Sometimes that’s not what you want, especially if you have custom row designs. To remove those lines, you just have to supply a value for tableFooterView. An empty UIView will work fine:

- (void) viewDidLoad
  [super viewDidLoad];

  self.tableView.tableFooterView = [[[UIView alloc] init] autorelease];

The table should now look like this:

No empty row lines