Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subviews not clipped on swipe left to delete UITableViewCell

I'm simply trying to implement swipe left and hit the delete button to remove a UITableViewCell.

On touch, the cell expands/contracts. The full size of the cell has been designed using Xcode and I have "Clip Subviews" ticked in order to prevent the bottom of the cell appearing in the contracted state.

However, when I swipe left on the contracted cell (to show the delete button), the bottom of the cell reappears! I've searched around for a solution but have yet to find one. Any help would be appreciated. Thanks.

like image 220
cud_programmer Avatar asked Aug 14 '14 17:08

cud_programmer


1 Answers

Full credit to Vitaliy Gozhenko, I am just duplicating an answer here. See this SO answer.

The issue is that cell.contentView.clipsToBounds is getting set to NO when the table enters edit mode.

To fix

- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.contentView.clipsToBounds = YES;
}

for me this was the fix needed for iOS8.

like image 163
ToddB Avatar answered Oct 12 '22 13:10

ToddB