Value of type 'UITableViewCell' has no member 'postImageView'

后端 未结 3 922
余生分开走
余生分开走 2021-01-25 22:26

New to iOS programming, I am getting the following error, I get it for 3 separate items, but solving one will solve them all.

I am getting the following error

Va

相关标签:
3条回答
  • 2021-01-25 23:02

    try changing the following lines:

    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! NewsTableViewCell
    
    ...
    
    return cell
    
    0 讨论(0)
  • 2021-01-25 23:09

    tableView.dequeueReusableCell returns a UITableViewCell which (as the compiler tells you) does not have the properties you are asking for. You will have to cast it to the expected type NewsTableViewCell:

    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! NewsTableViewCell

    0 讨论(0)
  • 2021-01-25 23:16

    The problem is that your cell object is a UITableViewCell and not a NewsTableViewCell. You need to dequeue a NewsTableViewCell that will actually have those properties on it.

    Something like:

    var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! NewsTableViewCell
    
    0 讨论(0)
提交回复
热议问题