zoukankan      html  css  js  c++  java
  • 2016-03-09 保存图片

    下面介绍我最后使用的一个办法。

    先把图片直接存储到沙盒中。 然后plist文件中记录图片的路径。然后要使用图片的时候通过访问plist文件获取图片路径来调用。

    下面是使用示例:

    一。图片存储到沙盒中

     

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

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

            [UIImagePNGRepresentation(myImage) writeToFile: filePath    atomically:YES];

     

    二。在plist中保存路径

     

     

    NSMutableDictionary *info = [[NSMutableDictionary alloc]init];

     

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

     

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

     

    [info setObject:filePath forKey:@"img"];

    [specialArr addObject:info];

     

    三。使用图片

     

     

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

    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"pic_%d.png", (int)current]];   // 保存文件的名称

    UIImage *img = [UIImage imageWithContentsOfFile:filePath];

  • 相关阅读:
    OCS边缘服务器部署(包含ISA设置)
    RMS部署文档
    推荐软件:PowerShell Plus
    OCS排错工具和最佳实践
    在Exchange Server 2007中使用多主机名称证书
    OCS边缘服务器部署
    推荐软件:Quset PowerGUI
    ISA 2008(FOREFRONT TMG)安装体验
    gridview 删除确认
    标识列 在任意编号位置插入数据
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5256937.html
Copyright © 2011-2022 走看看