So when I only have the myImageView1 in its fine but why is it giving me an error when I add myImageView2 in next to it separated by a comma. The error is at the uploadData part. How do I fix this?
@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)])
}
From the declaration of UIImagePNGRepresentation
:
func UIImagePNGRepresentation(_ image: UIImage) -> Data?
This function only takes one argument. You will need to get their data separately and find a way to combine them into one Data
object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.