0

我正在尝试将用户个人资料图片(文件)从 Parse 检索到我的PFQueryTableViewController. 我编写的代码没有给我错误,但是每次我运行我的应用程序时都会崩溃并说“无法将类型的值UIImageView转换为PFImageView。我是编码新手,不知道这意味着什么。有什么我必须修复我的代码?我只想检索用户图像以显示在我的查询中。下面是我的代码FeedViewController

        override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?, object: PFObject!) -> PFTableViewCell? {
       let cell = tableView!.dequeueReusableCellWithIdentifier("BubbleCell", forIndexPath: indexPath!) as! Bubbles


        if let userPost : PFObject = self.posts.objectAtIndex(indexPath!.row) as! PFObject {
/       if let pic = object["photo"] as? PFFile {
            // Make sure your imageView is a PFImageView
            let imageView = cell.userImage as! PFImageView
           // I assume this is the placeholder image while your load your image files from Parse
            imageView.image = UIImage(named: "image.png")
            imageView.file = pic
            // Load the image file however you see fit
           imageView.loadInBackground(nil) 
        }

这是我的代码PostViewController

   @IBAction func postPressed(sender: AnyObject) {



        let testObj = PFObject(className: "Test")

        testObj["photo"] = PFUser.currentUser()?.valueForKey("photo") as! PFFile

        testObj.saveInBackgroundWithBlock { (success:Bool, error :NSError?) -> Void in
            if error == nil
            {
                print("***///detail is saved///***")
                self.dismissViewControllerAnimated(true, completion: nil)
            }

    else {
        self.alert()
    }
        }
4

0 回答 0