删除UITableView的最后一行时出现动画问题 [英] Animation issue when deleting the last row of UITableView

查看:142
本文介绍了删除UITableView的最后一行时出现动画问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:现在已在iOS 8.0及更高版本中修复此问题。有关详细信息,请参阅我接受的答案。

UPDATE: This is now fixed in iOS 8.0 and above. See my accepted answer for details.

我有一个iOS 7 UITableView,我允许在行上滑动删除。我在处理删除:

I have an iOS 7 UITableView that I allow swipe-to-delete on rows. I'm handling deletions in:

tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

使用:

[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];

使用正确的动画删除所有行,但表格中的最后一行除外。当用户滑动以显示删除按钮,然后点击它时,单元格完全从屏幕向左滑动,但是在后面留下一个白色单元格,删除按钮仍在其上几十分之一秒,然后突然消失。似乎所有细胞都会发生这种情况,但所有其他细胞在它们下方都有一排向上滑动,覆盖它。

All rows are deleted with the correct animation, except for the last one in the table. When the user swipes to show the delete button, then taps it, the cell slides completely off screen to the left but leaves a white cell behind with the delete button still on it for a few tenths of a second before disappearing abruptly. It appears that this is happening with all the cells, but all other cells have a row below them that slides up, covering it up.

当行进入时问题是表中唯一的一行,我删除整个部分而不是行。部分标题滑动到遗忘状态,但带有删除按钮的白色单元格保持一点点。

This even happens when the row in question is the only row in the table, where I delete the entire section instead of just the row. The section header slides up into oblivion but the white cell with the delete button sticks around for a little bit.

我希望这最后一个单元格具有相同的UITableViewRowAnimationTop动画其他人呢。关于发生了什么的任何想法?

I would like this last cell to have the same UITableViewRowAnimationTop animation that the others do. Any ideas of what's going on?

推荐答案

更新:此错误已在iOS 8中得到纠正。最终的细胞删除现在滑落了在左侧,删除按钮向上和向外滑动,背景清晰(动画完成后不再有白色区域突然消失)。在iOS 8下运行时仍需要iOS 7以下修复。

UPDATE: This bug has been corrected in iOS 8. That final cell deletion now slides off to the left, the delete button slides up and away, and the background is clear (no more white area that abruptly disappears after the animations complete). The iOS 7 fix below is still needed when running below iOS 8.

iOS 7修复:
我能够通过添加另一部分来解决此问题表格末尾有一个足够高的部分标题视图。此标题视图的样式看起来像表格底部的空白区域,因此您无法看到它在那里。当删除表格的最后一行时,这个空白部分标题会向上滑动并隐藏它,隐藏那些卡在那里的删除按钮。这有点像黑客,但它看起来像是一个表视图错误。

iOS 7 Fix: I was able to correct this problem by adding another section to the end of the table with a sufficiently tall section header view. This header view is styled to look like the blank area at the bottom of the table, so you can't see that it's there. When the last row of the table is deleted, this blank section header slides up and over it, hiding the delete button that's stuck there. This is a bit of a hack, but it looks like it's a table view bug.

这篇关于删除UITableView的最后一行时出现动画问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆