0

Im getting this error and don't know why 'Cannot invoke 'insert' with an argument list of type '(Character, atIndex: Int)''

This code its working:

firstImageView.contentMode = .ScaleAspectFit

let imageData = UIImageJPEGRepresentation(pickedImage,0.75)

restaurante.imagem.insert(pickedImage, atIndex: imagemEscolhida-1)

This one is not:

firstImageView.contentMode = .ScaleAspectFit

let imageData = UIImageJPEGRepresentation(pickedImage,0.75)

restaurante.imagem.insert(imageData, atIndex: imagemEscolhida-1)

I just need to save to the array the image compressed and i must use "Insert" so i can choose "imagemEscolhida-1" to put the image in the right position... It works with the PickedImage, but once its compressed it doesnt work.

thank you.

4

1 回答 1

2

imageData 是一个 NSData 对象。您需要将其转换回 UIImage。

尝试这个:

firstImageView.contentMode = .ScaleAspectFit

let imageData = UIImageJPEGRepresentation(pickedImage,0.75)!
let compressedImage = UIImage(data: imageData)!

restaurante.imagem.insert(compressedImage, atIndex: imagemEscolhida-1)
于 2015-08-10T19:52:05.377 回答