• 图片保存到本地相册


    将图片保存到本地的相册中:

    //保存
    -(void)SaveAction{
        //保存到本地相册
        UIImageView *imgVCSave=[[UIImageView alloc]init];
        [imgVCSave setImageWithURL:[NSURL URLWithString:[_array_picURL objectAtIndex:_select_row]]];
        UIImageWriteToSavedPhotosAlbum(imgVCSave.image, self, @selector(imageSaveToPhoto:didFinishSavingWithError:contextInfo:), nil);
    }
    
    
    - (void)imageSaveToPhoto:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
    {
        NSString *message;
        if (!error) {
            message = @"成功保存到相册";
             [SVProgressHUD showSuccessWithStatus:message];
        }else
        {
            message = [error description];
        }
        NSLog(@"message is %@",message);
       
    }

    看一下官方文档:

    image

    The image to write to the Camera Roll album.

    completionTarget

    Optionally, the object whose selector should be called after the image has been written to the Camera Roll album.

    completionSelector

    The method selector, of the completionTarget object, to call. This optional method should conform to the following signature:

    - (void)               image: (UIImage *) image
        didFinishSavingWithError: (NSError *) error
                     contextInfo: (void *) contextInfo;
    contextInfo

    An optional pointer to any context-specific data that you want passed to the completion selector.

    Availability iOS (2.0 and later)
  • 相关阅读:
    基于组的策略(GBP)开启新型网络设计时代
    49 多维数组(二维数组)
    48 查找
    47 排序
    46 字符数组和字符串
    45 数组应用
    44 数组
    43 C语言宏定义
    42 预处理命令
    41 函数封装练习
  • 原文地址:https://www.cnblogs.com/niit-soft-518/p/4552631.html
Copyright © 2020-2023  润新知