cud_programmer
cud_programmer

Reputation: 1264

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.

Upvotes: 6

Views: 769

Answers (1)

ToddB
ToddB

Reputation: 2520

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.

Upvotes: 3

Related Questions