我正在我的应用程序中使用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]
}
if(indexPath.section != -1 && indexPath.row != -1) {
//Code for creating actions
}
return nil
此索引路径出现时,这至少应使其停止崩溃。