Swift 滑动以删除不存在的内容';我不能用定时器

Swift 滑动以删除不存在的内容';我不能用定时器,swift,Swift,我在我的TableView中实现了“滑动以删除”选项,如下所示: func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return true } func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath

我在我的TableView中实现了“滑动以删除”选项,如下所示:

func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
  return true
}

func tableView(_ tableView: UITableView, commit editingStyle: 
 UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
  if editingStyle == .delete {
    rows.remove(at: indexPath.row)
    runnerTableView.deleteRows(at: [indexPath], with: .fade)
    runnerTableView.reloadData()
  }
}
在实施我的计时器之前,它工作正常:

timer = Timer.scheduledTimer(timeInterval: 0.01, target: self, 
 selector:#selector(ViewController.updateTimer), userInfo: nil, repeats: true)
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)

func updateTimer () {
  var j = 0
  for _ in rows {
    if (rows[j]["Playing"] as! Bool == true ) {
      rows[j]["time"] = (rows[j]["time"] as! Double + 0.01) as AnyObject
    }
    j += 1
  }
  runnerTableView.reloadData()
}
编辑:

现在,滑动以删除不起作用。我刷卡时没有任何附加信息


我怎样才能使它再次工作

更新

  • updateTimer
  • 使用我的代码显示您的
    行[j][“时间”]
  • 原产地

    如果要显示计时器,可以使用以下选项:

    func updateTimer() {
        var j = 0
        for _ in rows {
            if (rows[j]["Playing"] as! Bool == true ) {
                rows[j]["time"] = (rows[j]["time"] as! Double + 0.01) as AnyObject
            }
            j += 1
        }
    
        for cell in tableView.visibleCells {
            if let indexPath = tableView.indexPath(for: cell) {
                cell.timeLabel.text = "\(rows[indexPath.row]["time"])"
            }
        }
    }
    

    1.我复制你的代码,它工作。2.我实现了你的定时器,它工作了。您在
    更新程序中做了什么?您不应该一直重新加载
    表视图
    @更新程序函数中的Codus?是的!updateTimer的间隔太短,并且您的数据源没有更改。是的,我将每0.03秒更新一次视图,TryI不想显示我的计时器,这已经完成,我正在尝试使用gif显示问题如果您不想显示计时器,则无需在
    行[j][“time”之后
    重新加载数据
    changedit已经完成了,我显示出来!但我可以试试你的方法,希望对你有所帮助:)