从Parse下载PFFile(Image)将其附加到数组并用该数组填充UIImageView(Swift)

我有解析和swift的问题,我希望你能帮助我:)

我正在从Parse下载字符串和PFfiles,并希望将其添加到数组中(这很好).

然后我想用字符串数组填充Label(也可以正常工作)和带有PFFile数组的UIImageView,它也是一个Image.

但我总是得到一个错误

PFFile is not convertible to “UIImage

但是我不知道如何转换这个PFFile以便我可以将它与UIImage View一起使用.

var titles = [String] ()

var fragenImages = [PFFile] ()

@IBOutlet weak var fragenIm: UIImageView!


@IBOutlet weak var fragenFeld: UILabel!



  override func viewDidAppear(animated: Bool) {


    var query = PFQuery(className:"Post")

    query.whereKey("user",notEqualTo: PFUser.currentUser().username)
    query.limit = 5

    query.findobjectsInBackgroundWithBlock{
        (objects: [AnyObject]!,error: NSError!) -> Void in

        if error == nil {



            for object in objects {

         self.titles.append(object["title"] as String)
         self.fragenImages.append(object["imageFile"] as PFFile)


            }



        self.fragenFeld.text = self.titles[0]
        self.fragenIm.image = self.fragenImages[0]





        }

            else {

            println(error)
            }

        }



}
丹尼尔,图片不是文件,从技术上讲它们是,但你将它们称为数据而不是PFObjects或PFFiles.因此,基本上获取文件的数据并按照通常的方式应用:您只是错过了一个简单的步骤:
for object in objects {
    let userPicture = object["imageFile"] as PFFile
    userPicture.getDataInBackgroundWithBlock({ // This is the part your   overlooking
    (imageData: NSData!,error: NSError!) -> Void in
    if (error == nil) {
    let image = UIImage(data:imageData)
    self.fragenImages.append(image)
})

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...