使用数组中的图像更新Tableview单元格

时间:2019-10-31 21:34:17

标签: swift uitableview parse-platform

我在视图中调用了一个名为getUserPicPostData的查询。输出显示阵列计数中有3张图像。

                      ViewdidLoad:
                      func getUserPicPostData() {
                       let query = PFQuery(className: "PicPost")
                     query.whereKey("Username", equalTo: usernameSelected)
                    query.findObjectsInBackground(block: { (objects: [PFObject]?,error: Error?) in
                    if let objects = objects {
                  for object in objects {

                    self.picLikeArray.append(object["UserLikes"] as! Int)
                    self.picTimeArray.append(object["UserTime"] as! String)
                    self.picObjectIdArray.append(object.objectId!)

                    let userImageFile = object["ImageFile"] as? PFFileObject

                      userImageFile?.getDataInBackground(block: { (imageData: Data?, error: Error?) in
                          if error == nil {
                            self.picPostArray.append(UIImage(data: imageData!)!)
                            print(self.picPostArray.count)
                          } else {
                              print(error)
                              }

                           })
                        } 
                     }
                  })

               }

然后我要告诉我的单元格接受imageArray的输入。 PicPostArray现在为零?

                         CellForRowAtIndexPath:
                        print(picPostArray)
                        cell.imageView1.imageView!.image = picPostArray[0]
                        cell.imageView2.imageView!.image = picPostArray[1]
                        cell.imageView3.imageView!.image = picPostArray[2]

0 个答案:

没有答案