我试图删除一个UITableViewCell的分隔符.我做了以下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
if (indexPath.row == 1)
cell.separatorInset = UIEdgeInsetsZero;
return cell;
}
(它是静态单元格)当我运行应用程序分隔线仍然在那里.如何删除一个单元格的分隔线?
解决方法
在iOS 8上,您需要使用:
cell.layoutMargins = UIEdgeInsetsZero
如果您想要与iOS 7兼容,您应该执行以下操作:
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
添加:如果以前没有工作 – 使用这个. (从下面回答)
cell.separatorInset = UIEdgeInsetsMake(0,1000,0);