Reputation: 5736
I made a custom UITableViewCell in IB, but for some reason, despite the single line option for separator being selected, there are no separator lines on my table.
Has this happened to any of you before? What gives?
Thanks!
Upvotes: 35
Views: 22157
Reputation: 2210
For anyone seeing this: My issue was that I had multiple sections, and the first cell in each section didn't have a separator. In my table view, I had overwritten the heightForHeader function (returning 0). Deleting this fixed the issue.
Upvotes: 1
Reputation: 371
If you programmatically add subviews to your cell, make sure you add the subviews
to cell.contentView and NOT to cell
[cell.contentView addSubview:subview];
Upvotes: 0
Reputation: 645
Just a heads up even though this is an old post:
If you are using the simulator and the UITableView separator is not showing up between cells it may be due to the fact that your window scale is too small.
Change this by going to Window->Scale->100%
Upvotes: 53
Reputation: 4279
Maybe an unlikely case, but there's another possible cause.
I have a custom UITableView
called AddressBookTableView and it is included in a .XIB for one of my view controllers. The thing I noticed was that it had been added as a UIView
element with custom class specified to be AddressBookTableView. I deleted this element and added a UITableView
element instead whose class I again specified to be AddressBookTableView and the separators magically reappeared!
Took me a super long time to find this...
Make sure your custom UITableView
.XIB elements are indeed custom UITableView
elements NOT renamed UIView
elements.
To be honest I'm surprised that the only noticeable artifact of this mistake was that the separators were missing. Other than that the UITableView still functioned normally?
Upvotes: 0
Reputation: 18428
I found separatorStyle
in UITableView class reference.
It says it will add separatorStyle to the cell returned by the delegate method, tableView:cellForRowAtIndex:.
So, I think you should modify the style property on the UITableView instance.
Upvotes: 2
Reputation: 4628
in my case I have to set the separatorStyle property of the tableView
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
Upvotes: 4
Reputation: 11359
In my case, i forgot to call [super layoutSubviews] after overriding the layoutSubviews method. Took me two hours to find the problem.
Upvotes: 35
Reputation: 15706
Is the UITableViewCell in IB associated with a UITableViewCell subclass that overrides drawRect:
? If so, make sure you are calling the super implementation, as that's what draws the line at the bottom. If you are overriding layoutSubviews
make sure no views are obscuring the bottom of the cell.
Upvotes: 53