Skip to content

Commit eb85d60

Browse files
author
hourunjing
committed
图片上加上 gif 标识&保存成功后加提示语:成功保存到相册
1 parent 80fc736 commit eb85d60

File tree

10 files changed

+110
-8
lines changed

10 files changed

+110
-8
lines changed

CodingForiPad.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
3EE2120A1B8F5CB4005AD963 /* NSTimer+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EE212091B8F5CB4005AD963 /* NSTimer+Common.m */; };
167167
3EFDAC0D1B80898700D7C7B6 /* COTweetDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EFDAC0C1B80898700D7C7B6 /* COTweetDetailCell.m */; };
168168
4066C8BA967EC44675BAEE39 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA54BD397E0D98238469E4BE /* libPods.a */; };
169+
8A9D08491C0DDD3F00FFF3ED /* gif_mark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8A9D08481C0DDD3F00FFF3ED /* gif_mark@2x.png */; };
169170
EB0046231B54F5A700B30971 /* COUserReNameController.m in Sources */ = {isa = PBXBuildFile; fileRef = EB0046221B54F5A700B30971 /* COUserReNameController.m */; };
170171
EB0046261B54F5C700B30971 /* COUserReTagController.m in Sources */ = {isa = PBXBuildFile; fileRef = EB0046251B54F5C700B30971 /* COUserReTagController.m */; };
171172
EB0046291B54F60800B30971 /* COUserRePositionController.m in Sources */ = {isa = PBXBuildFile; fileRef = EB0046281B54F60800B30971 /* COUserRePositionController.m */; };
@@ -645,6 +646,7 @@
645646
3EE212091B8F5CB4005AD963 /* NSTimer+Common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTimer+Common.m"; sourceTree = "<group>"; };
646647
3EFDAC0B1B80898700D7C7B6 /* COTweetDetailCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COTweetDetailCell.h; sourceTree = "<group>"; };
647648
3EFDAC0C1B80898700D7C7B6 /* COTweetDetailCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = COTweetDetailCell.m; sourceTree = "<group>"; };
649+
8A9D08481C0DDD3F00FFF3ED /* gif_mark@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "gif_mark@2x.png"; sourceTree = "<group>"; };
648650
A84BCA25F64E44D6DAD1DF4F /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
649651
E4C199B4F038A337F242DA4C /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
650652
EB0046211B54F5A700B30971 /* COUserReNameController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COUserReNameController.h; sourceTree = "<group>"; };
@@ -1876,6 +1878,7 @@
18761878
EB96D0021B46AE370072435A /* Resource */ = {
18771879
isa = PBXGroup;
18781880
children = (
1881+
8A9D08481C0DDD3F00FFF3ED /* gif_mark@2x.png */,
18791882
EB96D0031B46AE370072435A /* AssetsPickerChecked.imageset */,
18801883
EB96D0071B46AE370072435A /* camera.imageset */,
18811884
EB96D0091B46AE370072435A /* nav_delete_btn.imageset */,
@@ -2287,6 +2290,7 @@
22872290
EB96D0611B46AE370072435A /* paizhao@2x.png in Resources */,
22882291
EB96D06D1B46AE370072435A /* xiang@2x.png in Resources */,
22892292
EB96D06A1B46AE370072435A /* X.png in Resources */,
2293+
8A9D08491C0DDD3F00FFF3ED /* gif_mark@2x.png in Resources */,
22902294
EB96D05A1B46AE370072435A /* AssetsPickerChecked@2x.png in Resources */,
22912295
EB96D0621B46AE370072435A /* shanguangdeng.png in Resources */,
22922296
FEDEFC1C1B41A48C003585D1 /* bubble.html in Resources */,
1.47 KB
Loading

CodingForiPad/Utility/ZLPhotoLib/ZLPhotoBrowser/Views/ZLPhotoPickerBrowserPhotoScrollView.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "UIImageView+WebCache.h"
1212
#import "DACircularProgressView.h"
1313
#import "ZLPhotoPickerCommon.h"
14+
#import "SVProgressHUD.h"
1415

1516
// Private methods and properties
1617
@interface ZLPhotoPickerBrowserPhotoScrollView ()<UIActionSheetDelegate> {
@@ -97,7 +98,8 @@ - (void)longGesture:(UILongPressGestureRecognizer *)gesture
9798
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
9899
{
99100
if (buttonIndex == 0){
100-
UIImageWriteToSavedPhotosAlbum(_photoImageView.image, nil, nil, nil);
101+
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
102+
UIImageWriteToSavedPhotosAlbum(_photoImageView.image, self, selectorToCall, nil);
101103
}
102104
}
103105

@@ -424,4 +426,12 @@ - (void)view:(UIView *)view doubleTapDetected:(UITouch *)touch
424426
[self handleDoubleTap:CGPointMake(touchX, touchY)];
425427
}
426428

429+
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
430+
if (paramError == nil){
431+
[SVProgressHUD showSuccessWithStatus:@"成功保存到相册"];
432+
} else {
433+
[SVProgressHUD showErrorWithStatus:@"保存失败"];
434+
}
435+
}
436+
427437
@end

CodingForiPad/ViewController/Base/COAddMsgController.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
267267

268268
// 保存原图片到相册中
269269
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
270-
UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, NULL);
270+
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
271+
UIImageWriteToSavedPhotosAlbum(originalImage, self, selectorToCall, NULL);
271272
}
272273
[picker dismissViewControllerAnimated:YES completion:nil];
273274
} else {
@@ -340,4 +341,14 @@ - (void)sendImage:(id)image
340341
}];
341342
}
342343

344+
#pragma mark - save image
345+
346+
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
347+
if (paramError == nil){
348+
[self showSuccess:@"成功保存到相册"];
349+
} else {
350+
[self showErrorWithStatus:@"保存失败"];
351+
}
352+
}
353+
343354
@end

CodingForiPad/ViewController/Base/COAddProjectController.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,23 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
232232

233233
// 保存原图片到相册中
234234
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
235-
UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, NULL);
235+
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
236+
UIImageWriteToSavedPhotosAlbum(originalImage, self, selectorToCall, NULL);
236237
}
237238
[picker dismissViewControllerAnimated:YES completion:nil];
238239
} else {
239240
NSLog(@"请在真机使用!");
240241
}
241242
}
242243

244+
#pragma mark - save image
245+
246+
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
247+
if (paramError == nil){
248+
[self showSuccess:@"成功保存到相册"];
249+
} else {
250+
[self showErrorWithStatus:@"保存失败"];
251+
}
252+
}
253+
243254
@end

CodingForiPad/ViewController/Custom/COPhotoScrollView.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "COPhotoScrollView.h"
1010
#import "ZLPhoto.h"
1111
#import "UIButton+WebCache.h"
12+
#import "SVProgressHUD.h"
1213

1314
#define kPhotoBtnSpeace 20
1415

@@ -220,7 +221,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
220221

221222
// 保存原图片到相册中
222223
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
223-
UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, NULL);
224+
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
225+
UIImageWriteToSavedPhotosAlbum(originalImage, self, selectorToCall, NULL);
224226
}
225227
[picker dismissViewControllerAnimated:YES completion:nil];
226228
} else {
@@ -262,4 +264,14 @@ - (ZLPhotoPickerBrowserPhoto *)photoBrowser:(ZLPhotoPickerBrowserViewController
262264
return photo;
263265
}
264266

267+
#pragma mark - save image
268+
269+
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
270+
if (paramError == nil){
271+
[SVProgressHUD showSuccessWithStatus:@"成功保存到相册"];
272+
} else {
273+
[SVProgressHUD showErrorWithStatus:@"保存失败"];
274+
}
275+
}
276+
265277
@end

CodingForiPad/ViewController/Custom/EaseMarkdownTextView.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ - (void)pickerViewControllerDoneAsstes:(NSArray *)assets
252252
// 上传照片
253253
if (assets.count > 0) {
254254
ZLPhotoAssets *imageInfo = assets[0];
255-
[self doUploadPhoto:imageInfo.originImage];
255+
ZLPhotoPickerBrowserPhoto *photo = [ZLPhotoPickerBrowserPhoto photoAnyImageObjWith:imageInfo];
256+
[self doUploadPhoto:photo.photoImage];
256257
}
257258
}
258259

@@ -272,7 +273,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
272273

273274
// 保存原图片到相册中
274275
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera && originalImage) {
275-
UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, NULL);
276+
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
277+
UIImageWriteToSavedPhotosAlbum(originalImage, self, selectorToCall, NULL);
276278
}
277279

278280
// 上传照片
@@ -336,4 +338,14 @@ - (void)completionUploadWithResult:(id)responseObject error:(NSError *)error
336338
}
337339
}
338340

341+
#pragma mark - save image
342+
343+
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
344+
if (paramError == nil){
345+
[SVProgressHUD showSuccessWithStatus:@"成功保存到相册"];
346+
} else {
347+
[SVProgressHUD showErrorWithStatus:@"保存失败"];
348+
}
349+
}
350+
339351
@end

CodingForiPad/ViewController/Message/COMessageViewController.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
793793

794794
// 保存原图片到相册中
795795
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
796-
UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, NULL);
796+
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
797+
UIImageWriteToSavedPhotosAlbum(originalImage, self, selectorToCall, NULL);
797798
}
798799
[picker dismissViewControllerAnimated:YES completion:nil];
799800
} else {
@@ -854,4 +855,14 @@ - (UIImage *)backSpaceButtonImageForEmojiKeyboardView:(AGEmojiKeyboardView *)emo
854855
return img;
855856
}
856857

858+
#pragma mark - save image
859+
860+
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
861+
if (paramError == nil){
862+
[self showSuccess:@"成功保存到相册"];
863+
} else {
864+
[self showErrorWithStatus:@"保存失败"];
865+
}
866+
}
867+
857868
@end

CodingForiPad/ViewController/Tweet/COTweetImageCell.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#import "COUtility.h"
1212
#import "ImageSizeManager.h"
1313
#import "COTweetViewController.h"
14+
#import "View+MASAdditions.h"
1415

1516
@interface COTweetImageCell()
1617

1718
@property (nonatomic, strong) NSString *url;
19+
@property (strong, nonatomic) UIImageView *gifMarkView;
1820

1921
@end
2022

@@ -54,6 +56,24 @@ - (void)loadImage:(NSString *)imageUrl single:(BOOL)single
5456
[[NSNotificationCenter defaultCenter] postNotificationName:COTweetImageResizeNotification object:nil];
5557
}
5658
}
59+
60+
if ([imageUrl rangeOfString:@".gif"].location != NSNotFound) {
61+
if (!_gifMarkView) {
62+
_gifMarkView = ({
63+
UIImageView *imgView = [UIImageView new];
64+
imgView.image = [UIImage imageNamed:@"gif_mark"];
65+
[self.imageView addSubview:imgView];
66+
[imgView mas_makeConstraints:^(MASConstraintMaker *make) {
67+
make.size.mas_equalTo(CGSizeMake(24, 13));
68+
make.right.bottom.equalTo(self.imageView).offset(0);
69+
}];
70+
imgView;
71+
});
72+
}
73+
self.gifMarkView.hidden = NO;
74+
}else{
75+
self.gifMarkView.hidden = YES;
76+
}
5777
}
5878
}];
5979
}

CodingForiPad/ViewController/User/COUserDetailViewController.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
448448

449449
// 保存原图片到相册中
450450
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
451+
SEL selectorToCall = @selector(imageWasSavedSuccessfully:didFinishSavingWithError:contextInfo:);
451452
UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
452-
UIImageWriteToSavedPhotosAlbum(originalImage, self, nil, NULL);
453+
UIImageWriteToSavedPhotosAlbum(originalImage, self, selectorToCall, NULL);
453454
}
454455

455456
[picker dismissViewControllerAnimated:YES completion:nil];
@@ -458,4 +459,14 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
458459
}
459460
}
460461

462+
#pragma mark - save image
463+
464+
- (void) imageWasSavedSuccessfully:(UIImage *)paramImage didFinishSavingWithError:(NSError *)paramError contextInfo:(void *)paramContextInfo{
465+
if (paramError == nil){
466+
[self showSuccess:@"成功保存到相册"];
467+
} else {
468+
[self showErrorWithStatus:@"保存失败"];
469+
}
470+
}
471+
461472
@end

0 commit comments

Comments
 (0)