gpt4 book ai didi

ios - UITableViewRowAnimation 被忽略

转载 作者:可可西里 更新时间:2023-11-01 05:00:43 27 4
gpt4 key购买 nike

我正在使用 NSFetchedResultsController 来填充我的表。我表中的数据是根据时间戳升序排列的(最新消息在底部)。更多数据通过“无限滚动”加载到顶部:例如当用户滚动到顶部时,会加载更多消息。我的 NSFetchedResultsControllerDelegate 像往常一样定义,如 apple 文档中所建议的那样:新行通过

插入
- (void)controller:(NSFetchedResultsController*)controller
didChangeObject:(id)anObject
atIndexPath:(NSIndexPath*)indexPath
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath*)newIndexPath
{
switch(type) {
case NSFetchedResultsChangeInsert:
NSLog(@"insertion at row %d", newIndexPath.row);
[self.table insertRowsAtIndexPaths:@[newIndexPath]
withRowAnimation:UITableViewRowAnimationNone];

break;

现在这是我的问题:当插入新行时,它们总是动画为“向下”滑动。在无限向上滚动时,它看起来很糟糕。无论我是否将 UITableViewRowAnimationNoneUITableViewRowAnimationTopUITableViewRowAnimationBottom 作为参数传递,都会发生这种情况 - 该选项似乎被完全忽略。

关于如何正确地为表格设置动画有什么想法吗?

最佳答案

请尝试如下。

[CATransaction setDisableActions:YES];
[self.table insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationNone];
[CATransaction setDisableActions:NO]; // reset to original value

关于ios - UITableViewRowAnimation 被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15891330/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com