【问题标题】:Multiple UICollectionView PerformBatchUpdate多个 CollectionView PerformBatchUpdates
【发布时间】:2015-12-09 09:38:58
【问题描述】:

我正在UICollectionView 中使用自定义布局和流程制作一些动画。

当我想为我的UICollectionViews 设置动画时,我正在这样做:

    [localCollectionView performBatchUpdates:^{
         [localCollectionView insertItemsAtIndexPaths:indexPaths];
     } completion:^(BOOL finished) {
         [localLabelCollectionView performBatchUpdates:^{ //problem here
              [localLabelCollectionView insertItemsAtIndexPaths:indexPaths];

          } completion:^(BOOL finished) {
              hatching = NO;
          }];

     }];
  1. 使用批处理为我的第一个集合视图制作动画
  2. 完成后,为我的第二个集合视图设置动画

问题是当第一次立即执行时,第二次执行真的很慢(比如动画前 5 秒或更长时间),就像它的完成调用一样。

我什至试着像这样分开做:

    [localCollectionView performBatchUpdates:^{
         [localCollectionView insertItemsAtIndexPaths:indexPaths];
     } completion:^(BOOL finished) {
     }];

    [localLabelCollectionView performBatchUpdates:^{ //problem here
              [localLabelCollectionView insertItemsAtIndexPaths:indexPaths];

          } completion:^(BOOL finished) {
              hatching = NO;
          }];

出现同样的问题。欢迎任何建议或解释。

附:

对我来说,第一个解决方案必须工作,因为只使用主 UI 线程进行动画处理。这就是为什么我认为第二个示例(不处理最糟糕的 UI 动画)无法工作的原因。

【问题讨论】:

    标签: ios objective-c animation uicollectionview


    【解决方案1】:

    它是这样做的,并且像魅力一样工作:

    [localCollectionView performBatchUpdates:^{
         [localCollectionView insertItemsAtIndexPaths:indexPaths];
         [localLabelCollectionView insertItemsAtIndexPaths:indexPaths];
    } completion:^(BOOL finished) {
        hatching = NO;
    }];
    

    似乎 performBatch 在多次调用时更新入队本身(甚至在不同的对象上)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多