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

  • 相关阅读:
    Zebra命令模式分析(一)  分析
    sublime text2
    开源路由软件zebra的命令存储原理及使用方法
    开源路由软件zebra介绍和和在Linux环境下的安装
    jQuery删除节点
    如何成为一名软件架构师
    jQuery中的DOM操作
    编写自己的Shell解释器
    Notepad++集成VC2010环境
    ffmpeg使用语法
  • 原文地址:https://www.cnblogs.com/llios/p/3921912.html
Copyright © 2011-2022 走看看