我正在尝试从照片库加载图像并保存到手机的文档目录中,但是当我在文档目录中查看时,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

09-26 05:28