2
我有一個異步任務o執行計算和動畫,當動畫開始時,隊列掛起,當動畫結束時,隊列恢復。但由於某種原因,DispatchQueue.main.sync永遠不會被調用。DispatchQueue main不叫
self.someQueue = DispatchQueue(label: "Animation", qos: .background, attributes: DispatchQueue.Attributes.concurrent)
for index in stride(from: volumeObjects.count, to: -1, by: -1) {
mainAsyncQueue.sync{
self.dynamicViewModel.currentPercentile = Float(index)/Float(volumeObjects.count)
self.currentObjectIndex = index
print(index)
DispatchQueue.main.sync {
UIView.animate(withDuration: 1, animations: {
self.updateViewModelDynamicViewModel()
}, completion: { (finished) in
self.someQueue.resume()
})
}
self.someQueue.suspend()
}
}
這僅僅是計算量小,我就用它來解決的任務比
我看不出有任何* *異步任務。 'mainAsyncQueue'實際上是'backgroundSyncQueue';) – vadian
好的變量名納粹:P改變它 – RodolfoAntonici