Reputation: 3417
This is how my UITableView looks like:
I might cut the image to close to the last cell but there is no separator on the last cell.
When running this on my device that has IOS 7.1.1 It gets the same result until i scroll the view up and down a bit and then it automatically adds the separator. But trying that in the simulator which is running on IOS 8.2 as you can se nothing happens.
So what i want is simply so the separator is visible from the start.
Many thanks
EDIT1
After trying the answer below it did work however when there are a lot of cells and you scroll up then an extra separator shows up as you can see.
Check the third last cell. That extra separator just follows me when i go up and down.
EDIT2
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)])
{
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)])
{
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
-(void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
{
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
{
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section == 0)
return 76.0f;
else
return 25.0f;
}
Upvotes: 1
Views: 996
Reputation: 3417
This worked flawlessly for me
self.tableFooterView = [[UIView alloc] init]
Upvotes: 0
Reputation: 117
Use the two below UITableView delegate methods
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView* view = [UIView new];
[view setBackgroundColor:[UIColor grayColor]];
return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 1.0f;
}
Upvotes: 3