2017-05-05 43 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