从Firebase检索图像

时间:2017-06-02 13:59:45

标签: ios swift image firebase-realtime-database firebase-storage

Firebase Database Structure

的扩展名

将图像,姓名和电话上传到Firebase数据库和Firebase存储。

我无法将图像从Firebase检索到表格视图。

这是表视图类:

foreach(i=1:length(cuts), .packages = c("ggplot2","dplyr")) %do% {
  ggplot(filter(diamonds, cut == cuts[i])) +
    geom_line(aes(x = carat, y = price)) +
    theme(legend.position = "none") +
    ggtitle(cuts[i])
  ggsave(filename = paste0(i, ".png"))
}

这是表视图单元类:

@IBOutlet var tableViewHongKong: UITableView!

var restaurantList = [RestaurantModel]()

override func viewDidLoad() {
    super.viewDidLoad()

    ref = FIRDatabase.database().reference().child("restaurants")

    ref?.observe(FIRDataEventType.value, with: {(snapshot) in
        if snapshot.childrenCount>0
        {
            self.restaurantList.removeAll()

            for restaurants in snapshot.children.allObjects as![FIRDataSnapshot]
            {
                let restaurantObject = restaurants.value as? [String: AnyObject]
                let restaurantName = restaurantObject?["name"]
                let restaurantPhone = restaurantObject?["phone"]

                let restaurant = RestaurantModel(name: name as! String?, phone: phone as! String?)

                self.restaurantList.append(restaurant)
            }
        }
        self.tableViewHongKong.reloadData()
    })
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return restaurantList.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewControllerTableViewCell

    let restaurant: RestaurantModel

    restaurant = restaurantList[indexPath.row]

    cell.nameLabel.text = restaurant.name

    return cell
}
}

这是餐厅模特课:

@IBOutlet var myImage: UIImageView!

@IBOutlet var nameLabel: UILabel!

当图像上传到另一个班级,餐厅。

var name: String?
var phone: String?

init(name:String?, phone:String?) {
    self.name = name;
    self.phone = phone
}

有关详细信息,请访问Firebase Database Structure

非常感谢! ^。^

0 个答案:

没有答案