PFTableViewCell imageView是Nil(使用故事板)

时间:2014-07-17 14:42:03

标签: ios swift parse-platform

我创建了一个继承自PFTableViewCell的自定义类,由于某种原因,imageView为nil。谁知道问题可能是什么?我从故事板中将单元格出列。当我完全以编程方式生成类时,它很好。这是我的代码。

PFTableViewCell有一个名为imageView的属性,应该从子类中自动初始化(我想)。

类PhotoVC:PFQueryTableViewController

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {

    let CellIdentifier = "Cell"
    var cell : PhotoCell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier) as PhotoCell!

    if cell == nil {
        cell = PhotoCell(style: .Default, reuseIdentifier: CellIdentifier)
    }

    println(cell.imageView) //Always prints nil
}

类PhotoCell:PFTableViewCell

init(style: UITableViewCellStyle, reuseIdentifier: String!) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
}

当我尝试为imageView添加IBOutlet时,我收到错误。

error

1 个答案:

答案 0 :(得分:0)

据我所知,PFTableViewCell与标准样式不兼容。我瞥了一眼他们的代码(它的开源代码),评论表明他们确实在标准样式中遇到了imageView的问题。

我建议您使用imageView创建一个自定义单元格,您需要在故事板中将其设置为PFImageView 。 然后整个PFTableViewCell加载工作正常(这是它对我有用的唯一方式)。