iOS7
UITableViewCell
Separator Issue
iOS Development
Bug Fix

UITableViewCell Separator disappearing in iOS7

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

This old iOS 7 issue was usually not a mysterious rendering bug. It was mostly a separator inset issue introduced by the newer layout style. Cells still had separators, but the insets and margins made them appear missing or shifted in ways older table view code did not expect.

What Changed in iOS 7

Before iOS 7, developers often relied on the default separator behavior without touching insets. iOS 7 introduced new visual defaults, and table view separators became more sensitive to:

  • 'separatorInset'
  • layout margins
  • cell content width assumptions

So code that looked fine on older versions could suddenly appear to have no separator at all.

The Usual Fix: Zero the Insets

The common fix was to set separator insets to zero.

Objective-C example:

objc
1- (void)viewDidLoad {
2    [super viewDidLoad];
3
4    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
5        [self.tableView setSeparatorInset:UIEdgeInsetsZero];
6    }
7}

And often at the cell level too:

objc
1- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
2forRowAtIndexPath:(NSIndexPath *)indexPath {
3    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
4        [cell setSeparatorInset:UIEdgeInsetsZero];
5    }
6}

This made the separator span the expected width again.

Layout Margins Also Matter

Later iOS behavior introduced layoutMargins, so fixing only separatorInset was not always enough. If the cell or table view still had nonzero margins, the separator could remain visually offset.

A more complete compatibility approach looked like this:

objc
1- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
2forRowAtIndexPath:(NSIndexPath *)indexPath {
3    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
4        cell.separatorInset = UIEdgeInsetsZero;
5    }
6
7    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
8        cell.layoutMargins = UIEdgeInsetsZero;
9    }
10
11    if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
12        cell.preservesSuperviewLayoutMargins = NO;
13    }
14}

This became the stronger fix once layout margins entered the picture.

Check the Table Width and Style

Sometimes the separator was not fully gone. It was simply not where the developer expected because:

  • the table had grouped style rather than plain style
  • the cell width was changing
  • custom content or background views obscured the line

So if zeroing insets does not help, inspect:

  • table view style
  • custom cell background views
  • whether the separator color matches the background too closely

The visual result can look like a missing separator even when the real issue is contrast or layout.

Modern Perspective

This issue is historically tied to iOS 7-era table layouts, but the underlying lesson still matters: default UI metrics can change across system versions, and code that assumes exact default separator behavior is fragile.

If the UI depends heavily on exact separators, consider whether a custom separator view would be more predictable than relying on defaults. That gives you full control over width, color, and margins instead of inheriting platform behavior that may shift between OS releases.

That is not always necessary, but it is often the better choice for highly customized table view designs.

Common Pitfalls

  • Assuming the separator is gone when it is actually offset by inset or margin settings.
  • Fixing only separatorInset and ignoring layoutMargins.
  • Forgetting that grouped tables and custom backgrounds affect visual expectations.
  • Relying on default table appearance while also heavily customizing cells.
  • Treating the issue as random rendering behavior instead of a layout configuration issue.

Summary

  • The disappearing separator issue in iOS 7 was usually caused by inset and margin behavior.
  • Setting separatorInset to zero was the classic first fix.
  • In many cases, layoutMargins and preservesSuperviewLayoutMargins also needed adjustment.
  • Table style, backgrounds, and contrast can make a separator appear missing even when it exists.
  • The broader lesson is to avoid depending too heavily on fragile default UI metrics.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.