2017-05-05 47 views
0

我创建了一个表格视图,单元格是自定义样式,我没有使用dequeueReusableCell(withIdentifier:,for:)函数中的自定义类和单元格ID来挂钩单元格。无法设置自定义单元类的变量

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

但在覆盖FUNC的tableView(_的tableView:UITableView的,cellForRowAt indexPath:IndexPath) - >的UITableViewCell,我还是不能设置tableImage。该错误显示类型'UITableViewCell'的值没有成员'tableImage'。

+0

能否请您发布您的代码 – Welton122

+0

很难了解问题出在哪里,如果你不显示的代码,但似乎你忘了指定电池本身在与该行的终结“为!myCustomCellName“ – Alessign

+0

let cell = tableView.dequeueReusableCell(withIdentifier:”MyCell“,for:indexPath)as! CustomCell – Alessign

回答

1

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

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

哇,这太不可思议了......现在它在我添加它后立即生效!非常感谢! – CEz