开发者

delete/add button not showing in UITableViewCellStyleDelete/UITableViewCellStyleInsert

开发者 https://www.devze.com 2023-01-20 16:13 出处:网络
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 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 indent开发者_运维技巧ations 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消