zoukankan      html  css  js  c++  java
  • 保存图片信息通过NSData保存到本地文件中

    //第一步:保存头像信息到NSData中

       NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
       self.documentsPath = [paths objectAtIndex:0];  

    NSString *imagePath = [NSString stringWithFormat:@"%@/%@.jpg", self.documentsPath, contacts.Photo];
    UIImage *tempImage = [UIImage imageWithContentsOfFile:imagePath];
    headOldImageData = [NSData dataWithData:UIImageJPEGRepresentation(tempImage, 1.0)];
    [headOldImageData retain];

    //第二步:修改后用writeToFile归档

        NSString *imagePath = [NSString stringWithFormat:@"%@/%@.jpg", self.documentsPath, oldImageName];  
        

    if([fileManager fileExistsAtPath:imagePath]) { [headOldImageData writeToFile:[NSString stringWithFormat:@"%@/%@.jpg", self.documentsPath, oldImageName] atomically:YES]; }
  • 相关阅读:
    TS 3.1
    TS 3.1
    MDN 教程
    MDN 教程
    MDN 教程
    MDN 教程
    MDN 教程
    MDN 教程
    cookie会话技术
    数据库语法-1
  • 原文地址:https://www.cnblogs.com/allanliu/p/4521845.html
Copyright © 2011-2022 走看看