objective c – delete/add button not showing in UITableViewCellStyleDelete/UITableViewCellStyleInsert – Education Career Blog

I have a plain ol UITableView, and I want its cells to have the delete button on the left. I know this is done using UITableViewCellStyleDelete.

I set up my tableview like so:

adjustmentTable.rowHeight = 35.0; 
adjustmentTable setEditing:YES animated:YES;
adjustmentTable.allowsSelectionDuringEditing = YES;
adjustmentTable.userInteractionEnabled = YES;

With breakpoints, i know that this function is getting called:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row < tmpNumOfRows) {
        return UITableViewCellEditingStyleDelete;
    } 
    return UITableViewCellEditingStyleInsert;
}

and in my cellForRowAtIndexPath method, i set the cells editing mode to YES. When my tableview shows up, it has the indentations for the buttons on the left, but no buttons show up, its just a white indentation. Am I missing more steps to get the red/green buttons to show?

,

Writing that question me consider my last comment, setting the cells editing property to yes. For some reason, if you do this, the left add/delete buttons do not show up! I removed the code that did that and I see it now.

Perhaps someone can clarify why this is so with a comment.

Leave a Comment