please check my image for storing and retrieving dataswift - 将图像恢复为Firebase Swift时出现错误-LMLPHP
我得到了一个错误,因为我想从firebase检索图像,我的url是string,但是关于uiImage的错误状态不能是string,在那里我可以得到我的uiImageView的图像。
顺便说一下,这是下面用户的模型视图类
类用户{

    var username:String!
    var userage:String!
    var uid:String!
    var profileImageUrl: String!


    init (uid:String,dictionary:Dictionary<String,AnyObject>) {

    self.uid = uid
    if let username = dictionary [ "userName" ] as? String{

        self.username = username
    }

    if let userage = dictionary [ "useAge" ] as? String {

        self.userage = userage
    }

   if let profileImageUrl = dictionary["profileImageUrl"] as? String

 {

      self.profileImageUrl = profileImageUrl
   }


 }

    }

最佳答案

如果user.profileImageURL实际上是一个URL,则必须下载图像并将其分配给self.swipeLabel.image
若要从URL下载图像,请参阅以下文章:Create a UIImage with a URL in iOS
如果图像已存储,请使用以下代码。

self.swipeLabel.image = UIImage(contentsOfFile: profileimageurl)

关于swift - 将图像恢复为Firebase Swift时出现错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55740940/

10-14 16:59
查看更多