1
UICollectionView
を呼び出すためにUICollectionView
を呼び出すための適切な方法は、複数の起動を同時に防止し、インデックスパスが同期しないようにすることです挿入あり)chaining performBatchUpdates for collectionview
UICollectionView
を呼び出すためにUICollectionView
を呼び出すための適切な方法は、複数の起動を同時に防止し、インデックスパスが同期しないようにすることです挿入あり)chaining performBatchUpdates for collectionview
私はここであなたが探しているものはよく分かりません。 performBatchUpdate
を実行するときに複数のスレッドが互いに上書きしないようにするには、performBatchUpdate
へのすべての呼び出しがメインスレッドで呼び出されていることを確認する必要があります。例えば:あなたは同じスレッドでperformBatchUpdates
を複数回呼び出す方法を探しているなら
DispatchQueue.main.async {
collectionView.performBatchUpdates({
// perform a bunch of updates.
}, completion: { (finished: Bool) in
// anything that needs to happen after the update is completed.
}
}
はまた、(ええ、それはあなたがこれを必要とするだろうとやや奇妙だが、私は私がする必要がある場所を持っていますperformBatchUpdates
が完了しているので、第2のperformBatchUpdates
コールを最初の完了ハンドラに入れてみてください。
self.collectionView.performBatchUpdates({
// perform a bunch of updates.
}, completion: { (finished: Bool) in
self.collectionView.performBatchUpdates({
// perform a bunch of other updates.
}, completion: { (finished: Bool) in
})
})