保存图片/视频到相册 保存完成后通知事件 IOS

35 篇文章 0 订阅
// 官方提供的说明
//   - (void)image:(UIImage *)image didFinishSavingWithError :(NSError *)error contextInfo:(void *)contextInfo;
UIKIT_EXTERN void UIImageWriteToSavedPhoto sAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
//   - (void)video:(NSString *)videoPath didFinishSavingWithError :(NSError *)error contextInfo:(void *)contextInfo;
UIKIT_EXTERN void UISaveVideoAtPathToSaved PhotosAlbum(NSString *videoPath, id completionTarget, SEL completionSelector, void *contextInfo) __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_1);

---------------------------------------------------------------------------

#pragma mark -
#pragma mark - 存储图片或视频到相册的通知
@protocol SavedToPhotosAlbumDelega te

@optional

- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError :(NSError *)error contextInfo:(void *) contextInfo; 
- (void)videoSavedToPhotosAlbum:(NSString *)videoPath didFinishSavingWithError :(NSError *)error contextInfo:(void *)contextInfo;

@end

---------------------------------------------------------------------------
// 调用保存的时候直接调用这个
UIImageWriteToSavedPhoto sAlbum(image, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError :contextInfo:), nil);

// 保存图片到相册
+ (void) writeImageToPhotosAlbumB yImage:(UIImage *) v_image andCompletionTarget:(id) v_target andCompletionSelector:(SEL) v_selector andContextInfo:(void*) v_context {
       UIImageWriteToSavedPhoto sAlbum(v_image, v_target, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError :contextInfo:), v_context);
}
// 保存视频到相册
+ (void) writeVideoToPhotosAlbumB yVideoPath:(NSString *) v_strVideoPath andCompletionTarget:(id) v_target andCompletionSelector:(SEL) v_selector andContextInfo:(void*) v_context {
       UISaveVideoAtPathToSaved PhotosAlbum(v_strVideoPath, v_target, @selector(videoSavedToPhotosAlbum:didFinishSavingWithError :contextInfo:), v_context);
}
---------------------------------------------------------------------------
// 图片存放到相册后的通知
- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError :(NSError *)error contextInfo:(void *) contextInfo {  
       NSString *message;  
       NSString *title;  
       if (!error) {  
               title = @"Success";  
               message = @"Save album success!";  
       } else {  
               title = @"Failure";  
#if DEBUG_MODE
               message = [error description];
#else
              message = @"Failed to save the album!";
#endif
       }  
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title  
                                                                                                       message:message  
                                                                                                     delegate:nil  
                                                                                   cancelButtonTitle:@"OK"  
                                                                                   otherButtonTitles:nil];  
       [alert show];  
       [alert release];  
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值