0
我试图显示当前用户发布的所有图像。正如您在表格视图中的图片中看到的,每次当前用户发布图像时,它都会自动为当前用户信息下的图像创建唯一的ID。如何通过其uid的Swift Firebase获取图片?
在这个图像,你会看到,当用户上传的图像它创建一个名为节点为媒体与他们的孩子的形象。
这里是我的代码:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellMe", for: indexPath) as! MyPosttTableViewCell
FIRDatabase.database().reference().child("users").child(FIRAuth.auth()!.currentUser!.uid).observeSingleEvent(of: .value, with: { (snapshot) in
// check if user has photo
if snapshot.hasChild("media") != nil{
print("found it")
//set image locatin
let filePath = "\(FIRAuth.auth()!.currentUser!.uid)/\("media")"
FIRStorage.storage().reference().child(filePath).data(withMaxSize: 10*1024*1024, completion: { (data, error) in
let userPhoto = UIImage(data: data!)
cell.Myimages.image = userPhoto
})
}
else {
print("nil")
}
})
return cell
}}
我想在for循环下写什么? cell.myimages.image =? – ASH