Eliminate extra separators below UITableView

Interface builder (iOS 9+)

Just drag a UIView to the table. In storyboard, it will sit at the top below your custom cells. You may prefer to name it “footer”.

Here it is shown in green for clarity, you’d probably want clear color.

Note that by adjusting the height, you can affect how the “bottom bounce” of the table is handled, as you prefer. (Height zero is usually fine).

enter image description here


To do it programmatically:

Swift

override func viewDidLoad() {
    super.viewDidLoad()
    self.tableView.tableFooterView = UIView()
}

Objective-C

iOS 6.1+

- (void)viewDidLoad 
{
    [super viewDidLoad];

    // This will remove extra separators from tableview
    self.tableView.tableFooterView = [UIView new];
}

or if you prefer,

    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

Historically in iOS:

Add to the table view controller…

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
     // This will create a "invisible" footer
     return CGFLOAT_MIN;
 }

and if necessary…

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{        
    return [UIView new];

    // If you are not using ARC:
    // return [[UIView new] autorelease];
}

Leave a Comment