3

I'm creating tableviews and cells programmatically. The tableview cell separator moved in iOS 8,

enter image description here

even if I have already set:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kSomeNumber;
}

My app is ios7 and my phone is ios8. What could be the problem? I can't use cell.layoutMargins which is for ios8 only

Ted
  • 22,696
  • 11
  • 95
  • 109

1 Answers1

5

Since iOS8 we have layoutMargins which is causing your line.

If you have a custom cell, add this method to remove it:

- (UIEdgeInsets)layoutMargins 
{
     return UIEdgeInsetsZero;
}

Or add this in you uitableviewcontroller:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

   if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
   }
}

The responsToSelector is needed in order to support iOS7

Also check iOS 8 UITableView separator inset 0 not working for more info

Community
  • 1
  • 1
Sjoerd Perfors
  • 2,317
  • 22
  • 37
  • Thanks! Just implementing `-layoutMargins` in my custom UITableViewCell class did the trick (and works fine on iOS 7.) – race_carr Dec 02 '14 at 21:36