iOS-删除相册照片
#import <Photos/Photos.h>
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(takeScreenSheetAction:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
-(void)takeScreenSheetAction:(NSNotification *)notification{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@”creationDate” ascending:NO]];
PHFetchResult *assetsFetchResults = [PHAsset fetchAssetsWithOptions:options];
PHAsset *asset = [assetsFetchResults firstObject];
if (asset) {
NSArray *delAssets = [[NSArray alloc] initWithObjects:asset, nil];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
[PHAssetChangeRequest deleteAssets:delAssets];
} completionHandler:^(BOOL success, NSError * _Nullable error) {
}];
}
});
}