UIImageWriteToSavedPhotosAlbum(newImage, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
使用这种方法,我可以将图像保存在相册中,但不能限制再次将同一张照片保存在相册中
You can check whether file of same name exist at that path (Document-directory).
let fileManager = FileManager.default
var paths = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString)
paths = paths.appending("nameOfYourFile") as (NSString)
if !fileManager.fileExists(atPath: paths as String){
//no such file exist at this path
UIImageWriteToSavedPhotosAlbum(newImage, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.