사용자가 그림을 사진에서 프로그래밍 방식으로 만든 사용자 지정 앨범에 이미지로 저장하는 그림 앱을 만들고 있습니다. 저장된 이미지를 삭제하고 싶습니다. 사용자 지정 앨범에서 이미지를 삭제하는 방법을 알려주세요.
감사.
맞춤 앨범 삭제
IOS 10 이상 :
참고 : 사용자는 팝업 확인을 받게됩니다.
__block PHFetchResult *photosAsset;
__block PHAssetCollection *collection;
__block PHObjectPlaceholder *placeholder;
// Find the album
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
NSString * collectionTitle = //.. the custom album name
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"title = %@", collectionTitle];
// this is how we get a match for album Title held by 'collectionTitle'
NSArray * collections = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:fetchOptions];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
[collections enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
NSLog(@"Item %li = %@", (unsigned long)idx, obj);
[PHAssetCollectionChangeRequest deleteAssetCollections:@[obj]];
}];
} completionHandler:^(BOOL success, NSError *error) {
if (success)
{
NSLog(@"success");
NSLog(@"placeholder holds %@", placeholder.debugDescription );
}
else
{
NSLog(@"%@", error);
}
}];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다