I have a UITableView
and I have only 3 rows in it, and I can see those 3 rows. The problem is the cells that are empty: I can see lines there. I don't want to see those lines.
Any idea how to remove those lines?
Below is image for what I am looking for.
Even simpler than Andrey Z's reply: Simply make a bogus tableFooterView in your UITableView class:
self.tableFooterView = [UIView new]; // to hide empty cells
and Swift:
tableFooterView = UIView()
You can hide UITableView
's standard separator line by using any one of the below snippets of code. The easiest way to add a custom separator is to add a simple UIView
of 1px height:
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)]; separatorLineView.backgroundColor = [UIColor clearColor]; // set color as you want. [cell.contentView addSubview:separatorLineView];
OR
self.tblView=[[UITableView alloc] initWithFrame:CGRectMake(0,0,320,370) style:UITableViewStylePlain]; self.tblView.delegate=self; self.tblView.dataSource=self; [self.view addSubview:self.tblView]; UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)]; v.backgroundColor = [UIColor clearColor]; [self.tblView setTableHeaderView:v]; [self.tblView setTableFooterView:v]; [v release];
OR
- (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { // This will create a "invisible" footer return 0.01f; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { // To "clear" the footer view return [[UIView new] autorelease]; }
OR
And also check nickfalk's answer, it is very short and helpful too. And you should also try this single line,
self.tableView.tableFooterView = [[UIView alloc] init];
Not sure but it's working in all the version of iOS that I checked, with iOS 5 and later, up to iOS 7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With