各位大大好
小弟想在一个View上面使用一个tableview
并且在这个tableview上的不同section使用不同的的自定义Cell
不过在设定好之后我无法在cellForRowAt这个func里面调用该Cell的变量
会出现"Value of type 'UITableViewCell' has no member 'plusLabel'"的错误
在customCell里面也有建立一个customCell1.swift并且有IBOutlet做连结
cell是直接在tableview上面建立的,没有另外建立xib
如图
请问是哪里有问题呢?
是在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