工作,我必须实现“刷卡删除”我的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()
}
编辑:
现在,要删除的滑动功能不起作用。当我滑动时没有附加内容。
我该怎么办呢?
1.我复制你的代码,它的工作原理。 2.我实现你的计时器,它的工作原理。 你在'updateTimer'中做了什么? – Codus
你不应该重新加载你的'tableview'! – Codus
@coded updateTimer的函数? – pierreafranck