【发布时间】:2017-10-04 17:20:51
【问题描述】:
我想将图像从 imageview 保存到特定文件夹图像来自 Sqlserver。我想将它的链接保存在sqlite中以供进一步处理我已经编写了这段代码,它将图像保存在文档目录中,但每次路径都不同。请告诉我该怎么做?
let imageData = UIImagePNGRepresentation(imageee.image!)!
let docDir = try! FileManager.default.url(for: .picturesDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let imageURL = docDir.appendingPathComponent("tmp.png")
try! imageData.write(to: imageURL)
print(imageURL.path)
let newImage = UIImage(contentsOfFile: imageURL.path)!
//aftersave.image = newImage
aftersave.image = newImage
【问题讨论】:
-
你不是保存到documentDirectory,你是保存到picturesDirectory
-
我知道,但每次我重新运行令人困惑的模拟器时总是打印不同的路径....真的。
-
batter 选项是只创建一个应用程序名称的相册并将图像保存到其中。
-
怎么样?你能给我一些代码或任何文章吗?
-
@HammerClass 检查我的答案
标签: ios iphone swift sqlite uiimageview