Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tableviewcell separator moved in ios 8

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

like image 317
Ted Avatar asked Dec 02 '25 16:12

Ted


1 Answers

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

like image 109
Sjoerd Perfors Avatar answered Dec 05 '25 10:12

Sjoerd Perfors



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!