【问题标题】:Animating scroll in UICollectionView - iOS 10UICollectionView 中的动画滚动 - iOS 10
【发布时间】:2016-12-30 19:37:37
【问题描述】:

我正在以编程方式滚动我的收藏视图。它在除 iOS 10 之外的所有 iOS 版本上都能完美运行。集合视图在没有动画的情况下滚动,它只是卡入到位。

这是一个错误还是我应该在 iOS 10 中做一些不同的事情?

这是我的代码:

NSArray *visibleItems = [collectionViewReference indexPathsForVisibleItems];
NSIndexPath *currentItem = [visibleItems objectAtIndex:0];
NSIndexPath *previousItem = [NSIndexPath indexPathForItem:currentItem.item - 1 inSection:currentItem.section];
[collectionViewReference scrollToItemAtIndexPath:previousItem atScrollPosition:UICollectionViewScrollPositionRight animated:YES];

【问题讨论】:

  • 我在 iOS 10 上看到我的收藏视图出现了一些奇怪的行为。不是一回事,但收藏视图可能引入了一些错误。
  • 我也有同样的问题。当我用动画调用 scrollToItemAtIndexPath 时一切正常:NO 但动画时出现问题:YES
  • 尝试 collectionView.prefetchingEnabled = false。我在 10 上还有另一个性能问题,这有帮助。看起来它需要一些其他任务的主线程执行时间。

标签: ios objective-c uicollectionview ios10


【解决方案1】:

我可以重复一遍,但这确实对我有帮助。在设置我的 UIViewCollection 我设置: prefetchingEnabled = NO 而且这个错误没有重复,并且带有动画的 scrollItemAtIndexPath 工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多