我正在开发一个应用程序,可以从他们的照片库中选择一张图像,并将该图像的副本保存在同一日期。我相信图像是通过creationDate()在相机胶卷中排序的(如果我写错了,请纠正我),所以这就是我要更改的内容。我已经能够导入图像(作为UIImage)并将其保存到照片库中,但是我无法弄清楚如何修改日期,以便将其重新排列在照片列表中。这是我到目前为止所做的(保存图像),任何帮助将不胜感激:
@IBAction func save(_ sender: AnyObject) {
UIImageWriteToSavedPhotosAlbum(imageView.image!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}
//MARK: - Add image to Library
@objc func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error = error {
// we got back an error!
let ac = UIAlertController(title: "Save error", message: error.localizedDescription, preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
present(ac, animated: true)
} else {
let ac = UIAlertController(title: "Saved!", message: "Your altered image has been saved to your photos.", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
present(ac, animated: true)
}
}