IOS 7, UITableView and incorrect dividing lines

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

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

I tried to get "separatorInset" to use setSeparatorInset both the UITableView and in each individual cell, but this did not work. If I reloadData after adding a new line, the separator lines will be displayed correctly. But this does not seem to be the best solution.

Any ideas why the delimiter is not showing periodically?

+6
source share
5 answers

Enter this code in your ViewDidLoad method:

 [tblView setSeparatorInset:UIEdgeInsetsZero]; 
+12
source

For me, the only thing that works is reloading the previous cell, that is, the one that is above the selected cell.

 if (indexPath.row > 0) { NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section]; [tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone]; } 
+2
source

Apply your color in this method and this method to your code. This is an iOS7 update.

  - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { [cell setBackgroundColor:[UIColor clearColor]]; } 
0
source

Make sure that ClipCoBounds is set to YES for the cell, but NO for the contents of the cellView. Also set cell.contentView.backgroundColor = [UIColor clearColor];

0
source

use this.

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) { [tableView setSeparatorInset:UIEdgeInsetsZero]; } } 
0
source

Source: https://habr.com/ru/post/957819/


All Articles