[問題] tableView調用多種Cell
各位大大好
小弟想在一個View上面使用一個tableview
並且在這個tableview上的不同section使用不同的的自定義Cell
不過在設定好之後我無法在cellForRowAt這個func裡面調用該Cell的變數
會出現"Value of type 'UITableViewCell' has no member 'plusLabel'"的錯誤
在customCell裡面也有建立一個customCell1.swift並且有IBOutlet做連結
cell是直接在tableview上面建立的,沒有另外建立xib
如圖https://imgur.com/MWSVCNe
請問是哪裡有問題呢?
是在ustomCell的檔案裡面漏了什麼嗎?
下面貼上代碼
public func tableView(_ tableView: UITableView, cellForRowAt
indexPath: IndexPath) -> UITableViewCell {
var cell :UITableViewCell!
switch indexPath.section {
case 0:
cell = tableView.dequeueReusableCell(withIdentifier: "Cell1",
for: indexPath) as! customCell1
cell.plusLabel?.text = "" //<======這裡出現錯誤
case 1:
cell = tableView.dequeueReusableCell(withIdentifier: "Cell2",
for: indexPath) as! customCell2
cell.textLabel?.text = seceion4[indexPath.row]
default:
break
}
return cell
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 119.14.46.198
※ 文章網址: https://www.ptt.cc/bbs/MacDev/M.1515035741.A.202.html
推
01/04 12:04,
6年前
, 1F
01/04 12:04, 1F
推
01/04 12:04,
6年前
, 2F
01/04 12:04, 2F
→
01/04 12:05,
6年前
, 3F
01/04 12:05, 3F
→
01/04 12:06,
6年前
, 4F
01/04 12:06, 4F
→
01/04 12:06,
6年前
, 5F
01/04 12:06, 5F
→
01/04 12:07,
6年前
, 6F
01/04 12:07, 6F
→
01/04 12:08,
6年前
, 7F
01/04 12:08, 7F
→
01/04 12:09,
6年前
, 8F
01/04 12:09, 8F
→
01/04 12:13,
6年前
, 9F
01/04 12:13, 9F
→
01/04 12:14,
6年前
, 10F
01/04 12:14, 10F
推
01/04 12:19,
6年前
, 11F
01/04 12:19, 11F
推
01/04 12:22,
6年前
, 12F
01/04 12:22, 12F
→
01/04 12:52,
6年前
, 13F
01/04 12:52, 13F
→
01/04 12:53,
6年前
, 14F
01/04 12:53, 14F