【问题标题】:Invalid type for key imagem1, expected file, but got string密钥 imagem1 的类型无效,预期文件,但得到了字符串
【发布时间】:2015-08-10 18:05:27
【问题描述】:

我尝试使用UIImagePNGRepresentation,但是当我将图像上传到 Parse 时,它​​们太大了,但小图像工作正常。出于这个原因,我尝试使用UIImageJPEGRepresentation,但无论图像是大是小,总是会收到错误“键imagem1的类型无效,预期文件,但得到字符串”:

    let imageData = UIImageJPEGRepresentation(restaurante.imagem[0],0.75)
    let imageFile = PFFile(name:"image.png", data:imageData).description
    Restaurantes["imagem1"] = imageFile

    Restaurantes.saveInBackground()

有字符串吗?如何? 谢谢你:)

【问题讨论】:

    标签: ios swift parse-platform uiimagejpegrepresentation


    【解决方案1】:

    您已将.description 添加到定义的末尾,因此您正在创建您的PFFile 实例,然后获取它的描述。删除该行的那部分。

    【讨论】:

    • 不知道为什么会有 .description...但是谢谢!
    猜你喜欢
    • 2019-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-17
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    相关资源
    最近更新 更多