简体   繁体   English

向左滑动不会剪切子视图以删除UITableViewCell

[英]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. 我只是尝试实现向左滑动并点击删除按钮以删除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. 已经使用Xcode设计了单元格的完整大小,并且我勾选了“剪辑子视图”以防止单元格的底部出现在收缩状态。

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. 谢谢。

Full credit to Vitaliy Gozhenko, I am just duplicating an answer here. 完全归功于Vitaliy Gozhenko,我只是在这里重复一个答案。 See this SO answer . 看到这个答案

The issue is that cell.contentView.clipsToBounds is getting set to NO when the table enters edit mode. 问题是当表进入编辑模式时, cell.contentView.clipsToBounds被设置为NO

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. 对我来说这是iOS8所需的修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM