我收到此错误但不知道原因 '无法使用类型'(Character,atIndex:Int)''的参数列表调用'insert'
此代码正常工作:
firstImageView.contentMode = .ScaleAspectFit
let imageData = UIImageJPEGRepresentation(pickedImage,0.75)
restaurante.imagem.insert(pickedImage, atIndex: imagemEscolhida-1)
这个不是:
firstImageView.contentMode = .ScaleAspectFit
let imageData = UIImageJPEGRepresentation(pickedImage,0.75)
restaurante.imagem.insert(imageData, atIndex: imagemEscolhida-1)
我只需要保存到阵列压缩的图像,我必须使用“插入”,这样我就可以选择“imagemEscolhida-1”将图像放在正确的位置......它适用于PickedImage,但是一旦它压缩它不起作用。
谢谢。答案 0 :(得分:1)
imageData是一个NSData对象。你需要将它转换回UIImage。
试试这个:
firstImageView.contentMode = .ScaleAspectFit
let imageData = UIImageJPEGRepresentation(pickedImage,0.75)!
let compressedImage = UIImage(data: imageData)!
restaurante.imagem.insert(compressedImage, atIndex: imagemEscolhida-1)