无法设置自定义单元格类的变量

时间:2017-05-05 14:19:13

标签: swift custom-cell

我创建了一个表视图,单元格是自定义样式,我确实在dequeueReusableCell(withIdentifier: , for:)函数中使用自定义类和单元格的id连接单元格。

我在单元格中添加了一个图片视图,并将其作为IBOutlet添加到自定义单元格类中。在自定义单元格类中,我创建了名为tableImage的get和set变量来更改图像视图中的图像。

但是在

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

我仍然无法设置tableImage。错误显示类型UITableViewCell的值没有成员tableImage

1 个答案:

答案 0 :(得分:1)

你添加为! dequeueReusableCell函数之后的yourCustomTableViewCell?

yourTableView.dequeueReusableCell(withIdentifier: "yourCell", for: indexPath) as! yourCustomTableViewCell