Skip to main content

Separator Inset Problem - iOS 8

                   In iOS8, there is extra space in table view separators by default. It is nothing but the edge inset. To remove the separator edge inset, in iOS 7, custom separator insets can be set in the attributes inspector of the table view. In iOS 8, use the following in the table view controller:

//set edge inset zero for default separator
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath    {
 
  if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [self. tableView setSeparatorInset:UIEdgeInsetsZero];
  }
 
  if ([self. tableView respondsToSelector:@selector(setLayoutMargins:)]) {
    [self. tableView setLayoutMargins:UIEdgeInsetsZero];
  }
 
  if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsZero];
  }

}

Comments