为什么我在UIImageRepresentation中遇到2个不同字符串的错误?

时间:2017-06-27 15:44:32

标签: ios swift firebase swift3 uiimageview

所以当我只有myImageView1时它很好但为什么当我在旁边添加myImageView2并用逗号分隔时它会给我一个错误。错误发生在uploadData部分。我该如何解决这个问题?

@IBAction func upload(_ sender: Any) {


    let storageRef = Storage.storage().reference().child("images/\(NSUUID().uuidString)/image.png")
    if let uploadData = UIImagePNGRepresentation(self.myImageView1.image!){

        storageRef.putData(uploadData, metadata: nil, completion: { (metadata, error) in
            if error != nil {
                print("error")
                return
            }


            else {
                let downloadURL = metadata?.downloadURL()?.absoluteString
                self.ref?.child("Posts").childByAutoId().setValue(["Download URL": (downloadURL), "Download URL 2": (downloadURL2)])


            }

1 个答案:

答案 0 :(得分:1)

来自UIImagePNGRepresentation的声明:

func UIImagePNGRepresentation(_ image: UIImage) -> Data?

此函数只接受一个参数。您需要单独获取数据并找到将它们合并为一个Data对象的方法。