Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7, UITableView and incorrect separator lines

I have a problem in iOS 7 with UITableView (style: UITableViewStyleGrouped) and separatorInset. At times, the separator is not visible.

Briefly, using the same table (exactly the same code) if I render the table loading directly all data (for example from a NSArray), separator lines are correct (default iOS7 style, correct inset value). If I dynamically add new rows to the same table using something like insertRowsAtIndexPaths, separator lines span the full width of the cell/screen (so, no iOS7 default style).

I tried to force 'separatorInset' using setSeparatorInset in both UITableView and in every single cell but this did not worked. If I reloadData after adding a new row, the separator lines are correctly shown.but this seems not a great solution.

Any ideas why separator is intermittently not visible?

like image 449
M1K Avatar asked Nov 11 '13 09:11

M1K


2 Answers

Write this code in your ViewDidLoad method :

[tblView setSeparatorInset:UIEdgeInsetsZero];
like image 168
Dipak Narigara Avatar answered Sep 20 '22 05:09

Dipak Narigara


For me the only things working is reload the previous cell, i.e. the one that is on top of the selected cell.

if (indexPath.row > 0) {
    NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
    [tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];
}
like image 35
Pablosproject Avatar answered Sep 22 '22 05:09

Pablosproject