指定cell分割线补全:在cellForRowAtIndexPath代理中加入如下代码:
cell.preservesSuperviewLayoutMargins = NO;
cell.layoutMargins = UIEdgeInsetsZero;
cell.separatorInset = UIEdgeInsetsZero;
全局cell分割线补全:
在UIControllerView中加入重写如下方法:
- (void)viewDidLayoutSubviews {
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
if ([self respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[self setPreservesSuperviewLayoutMargins:NO];
}
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
指定cell分割线隐藏:首先保证指定cell分割线已经补全,然后加入如下代码:
cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, kDeviceWidth);
全局cell分割先隐藏:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;