我是swift平台的新手。我正在尝试将图像安装到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()
}
}
这是我的数据库:
我转过头来读写真实。
答案 0 :(得分:0)
我要查看与SELECT COUNT(collaborateur.DATE_ENTREE) AS nbrEntre , a.mnt,a.yr
FROM (
SELECT 01 as mnt,2013 as yr
UNION
SELECT 02 as mnt ,2013 as yr
UNION
SELECT 03 as mnt,2013 as yr
UNION
SELECT 04 as mnt,2013 as yr
UNION
SELECT 05 as mnt,2013 as yr
UNION
SELECT 06 as mnt,2013 as yr
UNION
SELECT 07 mnt,2013 as yr
UNION
SELECT 08 as mnt,2013 as yr
UNION
SELECT 09 as mnt,2013 as yr
UNION
SELECT 10 as mnt,2013 as yr
UNION
SELECT 11 as mnt,2013 as yr
UNION
SELECT 12 as mnt,2013 as yr
)
as a left join collaborateur on a.mnt=MONTH( collaborateur.DATE_ENTREE) and a.yr=DATE_FORMAT(collaborateur.DATE_ENTREE, "%Y") GROUP by YEAR(collaborateur.DATE_ENTREE), MONTH(collaborateur.DATE_ENTREE)
集成的FirebaseUI
,以便您可以这样做:
SDWebImage
每https://github.com/firebase/FirebaseUI-iOS/tree/master/FirebaseStorageUI