【发布时间】:2024-01-10 20:17:01
【问题描述】:
我正在制作一个应用程序,它使用不同颜色的单元格将单元格分成不同的类别,但我还有一个功能,允许用户点击单元格以添加复选标记并选择它们。我希望禁用彩色单元格,以便当用户点击它们时,他们不会向单元格添加复选标记并选择它。 这是我的复选标记功能:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cellIdentifier = "instrumentTableCell"
let cell: InstrumentTableCell! = tableView.dequeueReusableCellWithIdentifier(identifier) as? InstrumentTableCell
checked = Array(count:recipies.count, repeatedValue:false)
cell.configurateTheCell(recipies[indexPath.row])
if !checked[indexPath.row] {
cell.accessoryType = .None
} else if checked[indexPath.row] {
cell.accessoryType = .Checkmark
}
return cell
}
【问题讨论】:
-
cell.userInteractionEnabled有帮助吗? -
@paulvs 是的,谢谢!
-
我将其添加为答案。
-
如果您对某个答案感到满意,您可以通过单击帖子左侧的复选标记将其标记为已接受的答案。
标签: swift uitableview swift2 cell