使用以下代码,当我单击一个单元格以创建一个复选标记附件时,它会每12行重复一次复选标记.任何想法为什么?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as? UITableViewCell
cell?.textLabel = "\(indexPath.row)"
return cell!
}
func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
if let cell = tableView.cellForRowAtIndexPath(indexPath) as? UITableViewCell {
if cell.accessoryType == UITableViewCellAccessoryType.Checkmark
{
cell.accessoryType = UITableViewCellAccessoryType.None
}
else
{
cell.accessoryType = UITableViewCellAccessoryType.Checkmark
}
}
return indexPath
}
Run Code Online (Sandbox Code Playgroud)