有沒有辦法手動阻止隊列任務?我想在一個調度隊列任務中使用UIView動畫,但是這個任務只應該在動畫完成時完成。在動畫UIView時阻塞串行調度隊列
dispatch_queue_t myCustomQueue;
myCustomQueue = dispatch_queue_create("com.example.MyCustomQueue", NULL);
dispatch_async(myCustomQueue, ^{
[UIView animateWithDuration:myDuration
delay:0.0f
options:0
animations:^{
// my changes here
}
completion:nil];
});
dispatch_async(myCustomQueue, ^{
// if the animation from the task below is still running, this task should wait until it is finished...
});
1.我很慚愧地忘記了這一點。 2.但是,這是問題,在UIView動畫開始的時候,我不知道下一個任務。 – miho
在這種情況下,斯文的答案就是你的答案。 – jrturton
我將從主線程運行動畫,並在執行操作時暫停動作隊列。所以這是你的答案的組合。謝謝。 – miho