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