我正在尝试从照片库中加载图像并保存到手机的文档目录中,但是当我查看文档目录时,尚未创建PNG。我正在使用以下代码:
@IBAction func saveLogo(sender: AnyObject) {
if (pickedImage != nil) {
var fileName:String = "logo.png"
var arrayPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
var pngFileName = arrayPaths.stringByAppendingPathComponent(fileName)
UIImagePNGRepresentation(pickedImage).writeToFile(arrayPaths, atomically:true)
}
}
你可能想写信给pngFileName
而不是arrayPaths