1

For my UITableView I have such code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

But when I launch me app, it shows an extra separator. It's not additional cell - it cannot be selected. How can it be fixed?

Nikita Shytyk
  • 408
  • 7
  • 16
  • I bet this is the space between your different sections – KIDdAe Nov 08 '13 at 10:51
  • @KIDdAe But I have only one section – Nikita Shytyk Nov 08 '13 at 10:52
  • Is it a grouped or plain tableView ? (and are you really sure about having only one section ? Because there is no magical extra separator in iOS 7 :p) – KIDdAe Nov 08 '13 at 10:58
  • @KIDdAe it's a plain tableView. May be it's something like a bottom border of UITableView, I don't know( – Nikita Shytyk Nov 08 '13 at 11:01
  • 2
    possible duplicate of [Eliminate Extra separators below UITableView - in iphone sdk?](http://stackoverflow.com/questions/1369831/eliminate-extra-separators-below-uitableview-in-iphone-sdk) – Marcelo Nov 08 '13 at 11:02
  • Do you see this extra separator between every cells ? Is it only on iOS 7 ? Is it possible to have a screenshot ? – KIDdAe Nov 08 '13 at 11:02
  • @KIDdAe as far as I understood, it was a footer view. pcholberg's answer fixed it – Nikita Shytyk Nov 08 '13 at 12:11
  • @Nikita Shytyk If it was a footer problem, it's mean that you did have more than 1 section, since footerView appears at the end of each section ;). – KIDdAe Nov 11 '13 at 08:18

4 Answers4

7

Eliminate extra separators below UITableView

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{        
    return [UIView new];
    // If you are not using ARC:
    // return [[UIView new] autorelease];
}
Community
  • 1
  • 1
pcholberg
  • 520
  • 2
  • 17
  • This works, accept for when I navigate back to the tableview on the stack, it then draws a new separator only it is longer than the default. I have submitted a question here: http://stackoverflow.com/questions/21273709/issues-with-uitableviewcellseperator-reappearing-after-popping-from-the-stack – Kyle Begeman Jan 22 '14 at 03:42
2

With iOS7

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}
Aurelien Cobb
  • 435
  • 4
  • 6
0

It is by default in UITableView. You can use templates to create the kind of view you need, in an empty view controller (or) change the frame size of your UITableView in code by creating and allocating your own view.

Karthik Sivam
  • 2,505
  • 3
  • 18
  • 24
0

You can also try to set footer view height to zero, by using next code in UITableViewDelegate class:

- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0;
}
fir
  • 387
  • 1
  • 3
  • 19