• 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

  • 相关阅读:
    【Java123】enum枚举及其应用
    sql查询优化_慢查询
    9.4 如何实现属性可修改的函数装饰器?
    9.2 如何为被装饰的函数保存元数据?
    python的如何通过实例方法名字的字符串调用方法?
    9.1 如何使用函数装饰器 用装饰器解决重复计算问题
    asyncio 笔记
    python笔记截图
    list绑定
    表单数据交互
  • 原文地址:https://www.cnblogs.com/llios/p/3921912.html
Copyright © 2020-2023  润新知