【发布时间】:2016-10-27 11:57:59
【问题描述】:
我在我的应用程序中使用editActionsForRowAtIndexPath 来删除和编辑按钮,但如果我一次又一次地滑动更多时间,所以我一次得到indexpath.row = -1 我很震惊这是怎么可能的,但我有检查&在我得到相同indexpath.row = -1的任何地方访问更多演示项目。
那么我该如何处理呢,就像我希望滑动在这种情况下不起作用一样。
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
print(indexPath.row)
//Edit
let editAction = UITableViewRowAction(style: .Normal, title: "Edit", handler: {
action in
})
editAction.backgroundColor = UIColor(red: 212.0/255, green: 37.0/255, blue: 37.0/255, alpha: 1)
//Delete
let deleteAction = UITableViewRowAction(style: .Normal, title: "Delete", handler: {
action in
})
deleteAction.backgroundColor = UIColor(red: 183.0/255, green: 27.0/255, blue: 27.0/255, alpha: 1)
return [deleteAction,editAction]
}
【问题讨论】: