swift 中的 TableviewCell 问题
Issue with TableviewCell in swift
我有 2 个部分,都有 3 行。基本上我希望第 0 节第 0 行只有图像和标签组合。所有其他行将只包含文本。它在页脚上有一个注销。我该如何消除重复性,我知道这是因为我使用的是 dequereuseable 单元格,但我找不到解决方法。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ImageCell", for: indexPath) as! ImageViewCell
cell.textLabel?.font = UIFont(name: "Lato", size: 20.0)
cell.contentView.layer.borderWidth = 0.05
cell.layer.cornerRadius = 8
cell.userFirstName.text = userFirstName
return cell
}
您可以准备 2 个具有 2 种不同布局和不同标识符的不同单元格。然后根据 indexPath.section
和 indexPath.row
值将适当的出队。
我有 2 个部分,都有 3 行。基本上我希望第 0 节第 0 行只有图像和标签组合。所有其他行将只包含文本。它在页脚上有一个注销。我该如何消除重复性,我知道这是因为我使用的是 dequereuseable 单元格,但我找不到解决方法。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ImageCell", for: indexPath) as! ImageViewCell
cell.textLabel?.font = UIFont(name: "Lato", size: 20.0)
cell.contentView.layer.borderWidth = 0.05
cell.layer.cornerRadius = 8
cell.userFirstName.text = userFirstName
return cell
}
您可以准备 2 个具有 2 种不同布局和不同标识符的不同单元格。然后根据 indexPath.section
和 indexPath.row
值将适当的出队。