UITableView中的错误(deleteSections:withRowAnimation:)?
我有使用这个UITableView方法的问题:
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
首先文档说:
animation:是animation删除部分,否则不。
但参数animation实际上是枚举型的UITableViewRowAnimation
,而不是BOOL
!
那么如何禁用animation? 我试过NO
和UITableViewRowAnimationNone
。 没有任何工作 节删除总是animation。
我知道我可以使用[tableView reloadData]
来代替。 这将解决我的问题。 我只是好奇,如果这是一个已知的问题,如果可以禁用这个tableview方法的animation。
谢谢!
关于文档中的YES / NO,而参数是UITableViewRowAnimationtypes的,我想这是一个老版本的API,其中参数是一个BOOL之前的rest。 无论如何,文件确实是错误的。
不要犹豫,向苹果发送一个反馈(使用文档底部的“很好,但是…”链接)
这是一种黑客,但是这摆脱了插入animation:
[UIView setAnimationsEnabled:NO]; [self.tableView insertRowsAtIndexPaths:insertedIndexPaths withRowAnimation:UITableViewRowAnimationNone]; [UIView setAnimationsEnabled:YES];
那么,显然文件确实是越野车。 你传递的参数说明你如何animation删除。 如果您传递UITableViewRowAnimationNone
,则更新会在没有animation的情况下立即发生。 但是,如果您删除某个部分下方的部分,则会以animation方式向上移动。
你应该尝试使用animation。 这样用户可以看到发生了什么。
我相信你需要在beginUpdates
块中embeddeddeleteSections
调用:
[tableView beginUpdates]; [tableView deleteSections:... withRowAnimation:... ]; [tableView endUpdates];
无论如何, 文档似乎都是这样说的。 虽然我没有用UITableRowViewAnimationNone
testing过。