-1
私は高速プラットフォームで新しいです。イメージをFirebaseストレージにインストールしようとしています。その後、データベースから自分のapp.Iを検索し、インターネット上でいくつかのコードを発見し、お互いに関連付けます。 イメージが画面に印刷されません。 画像を印刷するにはどうすればいいですか?Firebaseストレージからイメージを取得するには
は、ここに私のコードです:
let ref = FIRDatabase.database().reference()
ref.child("images").queryOrderedByKey().observeSingleEvent(of: .value, with: { snapshot in
let images = snapshot.value as! [String : AnyObject]
self.places.removeAll()
for (_, value) in images {
let userToShow = historicalPlace()
if let img = value["place1"] as? String{
userToShow.historyImage = img
self.places.append(userToShow)
}
}
self.historyTableView.reloadData()
})
ref.removeAllObservers()
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = historyTableView.dequeueReusableCell(withIdentifier: "historyCell", for: indexPath) as! historyCell
cell.historyImage.downloadImage(from: places[indexPath.row].historyImage!)
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return places.count
}
}
extension UIImageView {
func downloadImage(from imgURL: String!) {
let url = URLRequest(url: URL(string: imgURL)!)
let task = URLSession.shared.dataTask(with: url) {
(data, response, error) in
if error != nil {
print(error!)
return
}
DispatchQueue.main.async {
self.image = UIImage(data: data!)
}
}
task.resume()
}
}
、これは私のデータベースです:
が、私は私の読み取りを向け、真の書き込み。