小编And*_*rin的帖子

UITableViewCell在swift中每12行重复一次

使用以下代码,当我单击一个单元格以创建一个复选标记附件时,它会每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)

uitableview ios swift

2
推荐指数
1
解决办法
1525
查看次数

标签 统计

ios ×1

swift ×1

uitableview ×1