我正在开发一个待办事宜应用程序。在我的应用程序中,我按下复选框按钮来删除一行。我为了给indexPath.row传递到我的复选框按钮编写代码:我如何将indexPath(而不是indexPath.row)传递给我的IBAction,用于我的UITableViewCell
cell.checkbox.tag = indexPath.row
cell.checkbox.addTarget(self, action: "checkAction:", forControlEvents: .TouchUpInside)
第一个代码可以让我获得indexPath.row,第二个让我创建一个功能是按下我的按钮时, 。这是我使用的功能,当按下按钮:
@IBAction func checkAction(sender: UIButton) {
taskMgr.removeTask(sender.tag)
tblTasks.reloadData()
}
现在,我想添加动画,它删除的时候,所以它看起来不那么突然。我会使用的代码是这样的:
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
但是,我只有在我的checkAction函数中访问indexPath.row。我如何访问indexPath(不牺牲indexPath.row)?
谢谢,这工作! – nintyapple