2017-04-10 18 views

答えて

0

私はここであなたが探しているものはよく分かりません。 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 
     }) 
    })