在我的應用程序中,我使用performSelectorInBackground:
從磁盤加載圖像。在使用dispatch_async進行一些單元測試後,我決定用dispatch_async調用替換我的performSelectorInBackground。dispatch_async slow then performSelectorInBackground:?
dispatch_queue_t currentBackgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(currentBackgroundQueue, ^{
[self getImageFromDisk:sPath delegate:(id)delegate];
});
該代碼似乎工作,但現在我的圖像加載速度較慢,然後之前。當用戶滾動圖像時,這會導致黑色圖像。
我的應用程序包含一些類型的photoscroller。我無法使用蘋果的平鋪示例代碼,因爲它將應用程序大小增加了很多。我使用this片段從磁盤加載圖像。
太好了,謝謝。我創建了一個自定義隊列,它工作正常! – Tieme
真棒很高興它的工作 –