I found a weird white space on UITableView
for iPhone 6 Simulator (iOS 8) on Xcode 6 GM. I have tried to set the SeparatorInset
from both storyboard and also the code, but the white space is till there.
The following code works on iOS 7 but not on iOS 8 (iPhone 6 simulator).
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
}
I attached screenshot below:
I am using AutoLayout by the way. I hope someone can show me a way to remove the weird white space on the TableView
.
Workaround for iOS 7 & iOS 8
To make your UITableView separator insets to zero for both iOS7 and iOS8, instead of making a change in the code, make a change in the xib for the UITableView by changing the View->Mode->Aspect Fill.
for iOS 8
try by setting
cell.layoutMargins = UIEdgeInsetsZero;
incellForRowAtIndexPath
methodI have static
UITableView
and wanted to shift the margin of a cell separator to the left edge.Thanks to the above answers, this was my solution
My solution with just three lines of code:
If you want to remove the white line, but keep separator inset as it is, just set the cell.backgroundColor to the tableView backgroundColor. Just setting the cell.contentView.backgroundColor does not make the problem disappear.