保存图片

保存到文件

//************** 存图片 *******************

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);

    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",@"jietu"]];   // 保存文件的名称

    NSLog(@"filePath = %@",filePath);

    //UIImagePNGRepresentation方法将image对象转为NSData对象

    //写入文件中

    BOOL result = [UIImagePNGRepresentation(image)writeToFile: filePath atomically:YES]; 

    NSLog(@"result = %d",result);

 保存到相册

UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);


//************** 存图片 *******************

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);

    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",@"jietu"]];   // 保存文件的名称

    NSLog(@"filePath = %@",filePath);

    //UIImagePNGRepresentation方法将image对象转为NSData对象

    //写入文件中

    BOOL result = [UIImagePNGRepresentation(image)writeToFile: filePath atomically:YES]; 

    NSLog(@"result = %d",result);

2 保存到相册

UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);











本文转自 卓行天下  51CTO博客,原文链接:http://blog.51cto.com/9951038/1772568,如需转载请自行联系原作者
上一篇:oracle数据库操作


下一篇:C# 将二进制字符串保存到本地