如何从Firebase提取图像以在scrollzVIew中显示

时间:2019-05-04 17:03:33

标签: ios swift firebase

我想找到一种从Firebase提取图像以显示在scrollzVIew

中的方法
 var rewardDataArr: [URL] = []
func showImageRewardData(rewardID:String,ImageView:UIImageView){

        let databaseRef = Database.database().reference().child("reward").child(rewardID).child("rewardImage")
        databaseRef.observe(DataEventType.value, with: { (Snapshot) in
            if Snapshot.childrenCount>0{

                for rewardImage in Snapshot.children.allObjects as! [DataSnapshot]{
                    let rewardObject = rewardImage.value as? [String: AnyObject]

                    if(rewardObject?["imageURL"] != nil){
                        let imageUrl = rewardObject?["imageURL"] as! String

                        rewardDataArr.append(NSURL(string: imageUrl)! as URL)

0 个答案:

没有答案