using swipe gesture to delete row on tableview

ぐ巨炮叔叔 提交于 2019-12-06 12:56:55

You can do this by implementing following UITableView deligate methods

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewCellEditingStyleNone; //if you don't want to show delete button
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
        return YES; // allow that row to swipe
        //return NO; // not allow that row to swipe
}

// Override to support editing/deleteing the table view cell on swipe.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleNone)
    {
        //--- your code for delete -----
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!