所以這是一個非常奇怪的廣告我不確定是否麻煩與AssetsLibrary API,但我無法弄清楚還有什麼可能發生。AssetsLibrary和ImageView -setImage Slowness
我正在使用ALAssetsGroup上的-enumerateAssetsUsingBlock方法加載ALAssets的數組。完成後,我正在加載自定義圖像滾動器。當滾動器完成滾動時,我使用NSInvocationOperations從磁盤上的照片庫中加載當前可見視圖(頁面)的圖像。一旦圖像被加載並被緩存,它就會通知委託人,然後從緩存中抓取圖像並將其顯示在滾動條的圖像視圖中。
一切工作正常,但從-setImage實際調用時間到實際顯示在屏幕上的時間是無法忍受的 - 有時甚至需要10秒或更長時間才能顯示出來。
我已經嘗試過,無論是否進行圖像大小調整,在調整大小時,幾乎沒有增加處理時間。正如我所說,放慢速度是在圖像視圖上調用-setImage之後的某處。有沒有人知道可能會導致此問題的AssetLibrary API的某些方面?
下面是一些相關的代碼:
- (void)setImagesForVisiblePages;
{
for (MomentImageView *page in visiblePages)
{
int index = [page index];
ALAsset *asset = [photos objectAtIndex:index];
UIImage *image = [assetImagesDictionary objectForKey:[self idForAsset:asset]];
// If the image has already been cached, load it into the
// image view. Otherwise, request the image be loaded from disk.
if (image)
{
[[page imageView] setImage:image];
}
else {
[self requestLoadImageForAsset:asset];
[[page imageView] setImage:nil];
}
}
}