ios – 仅为一个单元格删除分隔线

我试图删除一个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);

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...