table 视图中的 PFImage 太大

PFImage in table view too large

我正在使用解析。我的 table 中有一列用于将图像存储为 PFFile。我正在使用 PFQueryTableViewController。我想在我的 Parse table 的 "image" 列中显示图像作为每个 table 视图单元格的缩略图,该视图单元格具有与之关联的图像。

这是我怀疑的相关 cellForRowAtIndexPath 代码:

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

    // This works as you can see "grapes" displayed on the screenshot I added.
    var label = cell.viewWithTag(2) as UILabel
    label.text = object["title"] as? String

    // Accessing the PFImageView within my custom PFTableViewCell via a tag
    let imageView = cell.viewWithTag(3) as PFImageView

    // Extracting the image stored as a PFFile stored in the database
    imageView.file = object["image"] as? PFFile // remote image

    // Setting the actual thumbnail with the image when loaded 
    imageView.loadInBackground { (image: UIImage!, error: NSError!) -> Void in
        imageView.image = image
    }

    return cell
}

我在这个 Parse table 中存储了 2 条记录,第一个没有图像而第二个有(因此 "grapes" 单元格为空)。我的问题是,为什么图像没有显示在我创建的缩略图(适当限制)中,而是占据了整个屏幕?我在这里做错了什么?更奇怪的是,我使用 Xcode 的视图调试来捕获视图层次结构,它显示它正确放置在缩略图内。有什么想法吗?

您需要确保将图像模式设置为 "Scale To Fill"。