从UITableView中的deleteRowsAtIndexPaths不规则动画:withRowAnimation: [英] Irregular animations from UITableView's deleteRowsAtIndexPaths:withRowAnimation:
问题描述
摘要:
在编辑模式下,我在表视图中使用自定义编辑控制,而不是默认的红色减号和删除确认键删除行。勾选一行或多行,然后点击工具栏中的删除按钮。它类似于在邮件应用所看到的行为。请参见下面的截图。
Summary: In editing mode, I'm deleting rows in a table view using a custom editing control, rather than the default red minus sign and delete confirmation button. Tick a row or multiple rows, then tap the Delete button in the tool bar. It's similar to the behavior seen in the Mail app. See the screenshot below.
问题:
通过调用生产,以动画deleteRowsAtIndexPaths:withRowAnimation:
是不规则的。例如,这里所发生的事情时,我用的是下排的动画(即 UITableViewRowAnimationBottom
)删除选中的行(对象#7)的截图:
Problem:
The animations produced by calls to deleteRowsAtIndexPaths:withRowAnimation:
are irregular. For example, here's what happens when I use the Bottom row animation (i.e., UITableViewRowAnimationBottom
) to delete the ticked row (Subject #7) in the screenshot:
- 主题#8滑梯下面,背后的主题#7
- 主题#8简要背后隐藏的主题#7
- 主题#8替换对象#7刺耳
此发生在两个模拟器和设备上。自动动画类型(即 UITableViewRowAnimationAutomatic
)产生时删除对象#7上述相同的不规则行为。
This is occurring on both the simulator and on a device. The Automatic animation type (i.e., UITableViewRowAnimationAutomatic
) produces the same irregular behavior when deleting Subject #7 above.
名列前茅动画类型按预期工作在模拟器,但在设备上产生不一致,不和谐的动画。
The Top animation type works as expected in the simulator but produces inconsistent, jarring animations on a device.
淡入动画类型是预期在这两个模拟器和设备上唯一可行的动画。
The Fade type animation is the only animation that works as expected in both the simulator and on a device.
详细信息
我针对的iOS 7,并用故事板,纯自动布局和核心数据。
I'm targeting iOS 7, and using storyboard, pure auto layout, and Core Data.
下面的操作方法,我删除行:
Here's the action method where I delete the rows:
- (void)deleteButtonTapped:(UIBarButton *)sender
{
// update table view's data
[self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows];
// create index paths for ticked rows
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
[self.indexSetOfTickedRows enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[indexPaths addObject:[NSIndexPath indexPathForRow:idx inSection:0]];
}];
[self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationBottom];
// update Core Data and UI...
}
我曾尝试:
表格单元格的子类覆盖 layoutSubviews
。然而,不规则的动画仍然存在,甚至当我注释掉 layoutSubviews
。
The table cell subclass overrides layoutSubviews
. However, the irregular animations persist even when I comment out layoutSubviews
.
我也删除从表中的单元格的自定义编辑tickable控制,那么硬codeD中的操作方法的特定行的删除。不规则的动画仍然存在。
I also removed the custom tickable editing control from the table cells, then hard-coded the deletion of a specific row in the action method. The irregular animations persisted.
至于其他人的建议,我已经打过电话 deleteRowsAtIndexPaths:withRowAnimation:
呼叫 beginUpdates
之间 endUpdates
。这并不解决问题。
As suggested by others, I've tried calling deleteRowsAtIndexPaths:withRowAnimation:
between calls to beginUpdates
and endUpdates
. This does not resolve the issue.
这是下一步该怎么做任何建议,或者,为什么我看到这些不规则的动画最好的猜测?
Any suggestions on what to do next, or best guesses as to why I am seeing these irregular animations?
更新(的iOS 7.1):
问题依然瞄准的iOS 7.1之后。将继续依靠动画渐变。
Issue remains after targeting iOS 7.1. Will continue to rely on fade animation.
推荐答案
尝试调用 [self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows];
在功能,而不是在开始的末尾。
Try calling
[self.listOfItems removeObjectsAtIndexes:self.indexSetOfTickedRows];
at the end of the function instead of at the beginning.
这篇关于从UITableView中的deleteRowsAtIndexPaths不规则动画:withRowAnimation:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!