0
我知道這一點:如何僅用一個UIImageView顯示相冊中的所有照片?
imageView.image = aImage
現在我想告訴很多照片,即,在相冊中的所有照片。
let fetchResult = PHAsset.fetchAssetsWithLocalIdentifiers(Array(photoIDSet), options: nil)
let imageRequestOptions = PHImageRequestOptions()
imageRequestOptions.synchronous = true
imageRequestOptions.resizeMode = .Fast
fetchResult.enumerateObjectsUsingBlock({
fetchedObject, _, _ in
if let asset = fetchedObject as? PHAsset{
PHImageManager.defaultManager().requestImageForAsset(asset, targetSize: specialSize, contentMode: .AspectFit, options: imageRequestOptions, resultHandler: {
image, _ in
dispatch_async(dispatch_get_main_queue(), {
imageView.image = image
})
})
}
})
上述代碼無法按預期方式工作。如果幸運的話,它只會改變一次。
有沒有辦法?
創建資產數組。從資產中逐一獲取圖像,並通過在兩張圖像之間保持1秒的延遲來顯示圖像。 – Leena