Prevent indentation of UITableViewCell (contentView) while editing

前端 未结 9 775
心在旅途
心在旅途 2020-12-05 02:38

Is it possible to keep the contentView.frame always the same, regardless of tableView.editing? I already tried to override layoutSubviews

9条回答
  •  天命终不由人
    2020-12-05 02:48

    I had the same trouble with my plain style table even with shouldIndentWhileEditingRowAtIndexPath returning NO

    On my side, I encounter the issue because my first row should not be deleted and the rest of the table view cells should.

    I added this second method and it worked:

    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    
        if (indexPath.row == 0 && indexPath.section == 0) return NO;
    
        return YES;    
    }
    

    Hope it helps

提交回复
热议问题