X Tutup
Skip to content

Commit fe7789a

Browse files
committed
3840 提示语 & 私信对话框尺寸 & Gif 图片保存
1 parent 0d50a2a commit fe7789a

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Coding_iOS/Controllers/FileViewController.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -440,18 +440,18 @@ - (void)openByOtherApp{
440440
}
441441

442442
- (void)saveCurImg{
443-
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
444-
445-
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:self.fileUrl]];
446-
if (!image) {
447-
[NSObject showHudTipStr:@"提取图片失败"];
448-
return;
449-
}
450-
UIImageWriteToSavedPhotosAlbum(image, self, selectorToCall, NULL);
443+
__weak typeof(self) weakSelf = self;
444+
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
445+
[[PHAssetCreationRequest creationRequestForAsset] addResourceWithType:PHAssetResourceTypePhoto fileURL:weakSelf.fileUrl options:nil];
446+
} completionHandler:^(BOOL success, NSError * _Nullable error) {
447+
dispatch_async(dispatch_get_main_queue(), ^{
448+
[weakSelf saveImageHappenedError:error];
449+
});
450+
}];
451451
}
452452

453-
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
454-
if (paramError == nil){
453+
- (void)saveImageHappenedError:(NSError *)error{
454+
if (error == nil){
455455
[NSObject showHudTipStr:@"成功保存到相册"];
456456
} else {
457457
[NSObject showHudTipStr:@"保存失败"];

Coding_iOS/Vendor/MJPhotoBrowser/MJPhotoToolbar.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,21 @@ - (void)setPhotos:(NSArray *)photos
5555
[self addSubview:_saveImageBtn];
5656
}
5757

58-
- (void)saveImage
59-
{
60-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
61-
MJPhoto *photo = _photos[_currentPhotoIndex];
62-
UIImageWriteToSavedPhotosAlbum(photo.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
63-
});
58+
- (void)saveImage{
59+
MJPhoto *curP = _photos[_currentPhotoIndex];
60+
NSString *dataP = [SDWebImageManager.sharedManager.imageCache defaultCachePathForKey:curP.url.absoluteString];
61+
NSData *imageD = [NSData dataWithContentsOfFile:dataP];
62+
__weak typeof(self) weakSelf = self;
63+
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
64+
[[PHAssetCreationRequest creationRequestForAsset] addResourceWithType:PHAssetResourceTypePhoto data:imageD options:nil];
65+
} completionHandler:^(BOOL success, NSError * _Nullable error) {
66+
dispatch_async(dispatch_get_main_queue(), ^{
67+
[weakSelf saveImageHappenedError:error];
68+
});
69+
}];
6470
}
6571

66-
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
67-
{
72+
- (void)saveImageHappenedError:(NSError *)error{
6873
if (error) {
6974
[MBProgressHUD showSuccess:@"保存失败" toView:nil];
7075
} else {

0 commit comments

Comments
 (0)
X Tutup