目標:用戶從她的照片庫中選擇照片>點擊「完成」>照片顯示。如何顯示剛剛選擇的照片庫中的圖像?
問題:「完成」後照片不會立即顯示。如果我再次打開拾取器並點擊「取消」,它們會顯示出來。
當我使用UIImagePickerController時,這工作正常(照片顯示立即),但後來我切換到ELCImagePickerController多選,它不再起作用。
預感
- 的CollectionView顯示所有圖像沒有被重新加載?但在圖像被選中後(在完成處理程序上),我嘗試調用
collectionView.reloadData()
。這沒有奏效。
如果有幫助,這是我的elcImagePickerController
功能從我ViewController.swift
func elcImagePickerController(picker: ELCImagePickerController!, didFinishPickingMediaWithInfo info: [AnyObject]!) {
println("inside elcImagePickerController")
self.dismissViewControllerAnimated(true, completion: nil)
if (info.count == 0) {
return
}
var pickedImages = NSMutableArray()
for any in info {
let dict = any as! NSMutableDictionary
let image = dict.objectForKey(UIImagePickerControllerOriginalImage) as! UIImage
pickedImages.addObject(image)
}
let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_async(dispatch_get_global_queue(priority, 0), {
PHPhotoLibrary.sharedPhotoLibrary().performChanges(
{
for img in pickedImages{
// Request creating an asset from the image
// create multiple creationRequestForAssetFromImage
let createAssetRequest = PHAssetChangeRequest.creationRequestForAssetFromImage(img as! UIImage) // add to main gallery
///Request editing the album
let albumChangeRequest = PHAssetCollectionChangeRequest(forAssetCollection: self.assetCollection, assets: self.photosAsset)
// Get a placeholder for the new asset and add it to the album editing request
let assetPlaceholder = createAssetRequest.placeholderForCreatedAsset
albumChangeRequest.addAssets([assetPlaceholder])
}
}, completionHandler: {(success, error) in
NSLog("Adding Image to Library -> %@", (success ? "Success" : "Error"))
picker.dismissViewControllerAnimated(true, completion: nil)
}
)
})
哎...阿斯我已經使用ELCImagePickerController到我的應用程序來選擇多個圖像。在ELCImagePickerController中選擇圖像顯示在Imageview中的滾動視圖,但我想在集合視圖中顯示那些選定的圖像,而不是在目標c中的滾動視圖。請給我代碼。我嘗試了很多。 –