zoukankan      html  css  js  c++  java
  • IOS UIImagePickerController 保存图片到 相册

     // 异步下载图片

            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

  • 相关阅读:
    centos7系统修改内核
    使用yum update更新文件系统时不更新内核的方法
    实现让用户不断的猜年龄,但只给最多3次机会,超过次数猜不对就退出程序。
    yum安装软件中的y/d/N
    MySQL5.7.15数据库配置主从服务器实现双机热备实例教程
    CentOS7.2 多个python版本共存
    CentOS 7.2 安装Python3.5.2
    R语言与概率统计(五) 聚类分析
    R语言与概率统计(四) 判别分析(分类)
    R语言与概率统计(三) 多元统计分析(下)广义线性回归
  • 原文地址:https://www.cnblogs.com/llios/p/3921912.html
Copyright © 2011-2022 走看看