码迷,mamicode.com
首页 > 移动开发 > 详细

IOS UIImagePickerController 保存图片到 相册

时间:2014-08-19 14:13:24      阅读:719      评论:0      收藏:0      [点我收藏+]

标签:os   io   ad   ef   on   sp   ios   ui   

 // 异步下载图片

        dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);

        dispatch_group_t group =dispatch_group_create();

        dispatch_group_async(group, queue, ^{

            NSData *data = [NSDatadataWithContentsOfURL:[NSURLURLWithString:imageUrl]];

            UIImage *image = [UIImageimageWithData:data];

                //  保存图片到相册

                [PDPhotoGraphToolsaveImageToPhotos:image];

        });

 

 

 

@interface PDPhotoGraphTool: NSObject

 

+ (void)saveImageToPhotos:(UIImage *)savedImage;

 

 

+ (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) errorcontextInfo: (void *) contextInfo;

@end

 

 

@implementationPDPhotoGraphTool

 

+(void)saveImageToPhotos:(UIImage *)savedImage

{

   

    UIImageWriteToSavedPhotosAlbum(savedImage,self,@selector(image:didFinishSavingWithError:contextInfo:),NULL);

}

 

+(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)errorcontextInfo:(void *)contextInfo

{

    NSString *msg = nil ;

   

    if(error != NULL){

       

        msg = @"保存图片失败" ;

       

    }else{

       

        msg = @"保存图片成功" ;

       

    }

   

    UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"保存图片结果提示"

                         

                                                   message:msg

                         

                                                  delegate:self

                         

                                          cancelButtonTitle:@"确定"

                         

                                          otherButtonTitles:nil];

   

    [alert show];

 

}

@end

IOS UIImagePickerController 保存图片到 相册,布布扣,bubuko.com

IOS UIImagePickerController 保存图片到 相册

标签:os   io   ad   ef   on   sp   ios   ui   

原文地址:http://www.cnblogs.com/llios/p/3921912.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!