for asset in assets{
let phasest = asset.originalAsset
print(phasest?.mediaType)
let currentPhasset = PHAsset.fetchAssetsWithMediaType(phasest?.mediaType, options: nil)
asset.fetchFullScreenImageWithCompleteBlock({ (image, info) -> Void in
orignalImages.append(image!)
print (info)
let fetchResult = currentPhasset
let lastAsset: PHAsset = fetchResult[1] as! PHAsset
print(fetchResult)
let arrayToDelete = NSArray(object: lastAsset)
PHPhotoLibrary.sharedPhotoLibrary().performChanges( {
PHAssetChangeRequest.deleteAssets(arrayToDelete)},
completionHandler: {
success, error in
NSLog("Finished deleting asset. %@", (success ? "Success" : error!))
})
我使用dkimagecontroller来选择图像。在我的代码中我可以删除第一张照片,因为我在获取结果中传递索引1。如果我传递任何更大的数字,它将删除空数据。那么如何删除所选图像?我
答案 0 :(得分:0)
for asset in assets{
let phasest = asset.originalAsset
asset.fetchFullScreenImageWithCompleteBlock({ (image, info) -> Void in
orignalImages.append(image!)
if (phasest != nil) {
let arrayToDelete = NSArray(object: phasest!)
PHPhotoLibrary.sharedPhotoLibrary().performChanges( {
PHAssetChangeRequest.deleteAssets(arrayToDelete)},
completionHandler: {
success, error in
NSLog("Finished deleting asset. %@", (success ? "Success" : error!))
})
}