Жодне з цих рішень не працює на iPad, але я придумав рішення, яке охоплює обидва пристрої:
З клітинами для багаторазового використання:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
...[other code]...
[cell setLayoutMargins:UIEdgeInsetsZero];
[cell setSeparatorInset:UIEdgeInsetsZero];
return cell;
}
З клітинами, які не використовуються повторно:
- (void)removeSeparatorInset:(UITableView*)tableView{
NSArray *cells = [tableView visibleCells];
for (UITableViewCell *cell in cells){
[cell setLayoutMargins:UIEdgeInsetsZero];
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
-(void) viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
[self removeSeparatorInset:self.tableView];
}
Просто для розширення цього підходу:
@property(nonatomic) UIEdgeInsets separatorInset;
@property(nonatomic) UIEdgeInsets layoutMargins;
Обидві властивості можуть використовувати UITableView& UITableViewCell. Останнє насправді є властивістю UIView, яке є батьківським класом обох UITableView& UITableViewCell.
UITableViewмає властивістьseparatorInset. ВстановитиUITableViewроздільник рядків на нуль. Крім того, ви можете змінитиseparatorInsetз розкадровки