tableView非iOS11系统使用cell.separatorInset,会有一根线

我通过隐藏全部分割线,手动画线已经解决了该BUG,只是不知道这个BUG为何会产生,特地来请教.
这是我的tableView

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain]; // 把tableView Style设置为UITableViewStyleGrouped,就不会有section停留效果
        _tableView.backgroundColor = HEXCOLOR(0xf5f5f5);
         _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;   // 隐藏系统分割线
        _tableView.tableFooterView = [[UIView alloc] init]; // 没数据的时候不显示分割线
        _tableView.rowHeight = CMHeightPixel * 100;
        _tableView.delegate = self;
        _tableView.dataSource = self;
  
        }
        [self.view addSubview:_tableView];
    }
    return _tableView;
}

创建cell的代理方法里面的代码:

if (indexPath.row == 2) { // 指定去除row2的分割线
    cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, kScreenWidth);
}

图片描述

阅读 4.2k
1 个回答
新手上路,请多包涵

rowHeight 高度不精确导致的,使用 floor 或者 ceil函数可以解决这个问题

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题