当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS 沙盒图片保存读取实例

iOS 沙盒图片保存读取实例

2019年07月24日  | 移动技术网IT编程  | 我要评论

砸钱宝马女微博,起网名,移动迷宫3:死亡解药 电影

实例如下所示:

//保存图片
-(void)saveimagedocuments:(uiimage *)image{
  //拿到图片
  uiimage *imagesave = image;
  nsstring *path_sandox = nshomedirectory();
  //设置一个图片的存储路径
  nsstring *imagepath = [path_sandox stringbyappendingstring:@"/documents/test.png"];
  //把图片直接保存到指定的路径(同时应该把图片的路径imagepath存起来,下次就可以直接用来取)
  [uiimagepngrepresentation(imagesave) writetofile:imagepath atomically:yes];
}
// 读取并存贮到相册 
-(uiimage *)getdocumentimage{
  // 读取沙盒路径图片
  nsstring *apath3=[nsstring stringwithformat:@"%@/documents/%@.png",nshomedirectory(),@"test"];
  // 拿到沙盒路径图片
  uiimage *imgfromurl3=[[uiimage alloc]initwithcontentsoffile:apath3];
  // 图片保存相册
  uiimagewritetosavedphotosalbum(imgfromurl3, self, nil, nil);
  return imgfromurl3;
}

以上这篇ios 沙盒图片保存读取实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网