• 保存图片信息通过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]; }
  • 相关阅读:
    Jetson Nano更改软件源
    树莓派开机启动VNC
    树莓派VNC复制粘贴
    数学之美-泰勒公式
    C++顺序容器
    eigen的简单用法汇总
    C++并发-同步并发
    C++ string类
    C++并发-互斥元
    Nginx常用命令
  • 原文地址:https://www.cnblogs.com/allanliu/p/4521845.html
Copyright © 2020-2023  润新知