开发者

How to set a custom edit-style icon in a UITableViewCell while in edit mode

Is there any way to have a custom edit-style icon (besides the green plus and red minus icons) when enabling edit-mode in a UITableView开发者_如何学运维?

I know I could simulate the the edit-mode animation and just move the cell contents to the right and add a UIImageView, but I was trying to avoid that.


The only way to customize the editing style of a cell is using tableView:editingStyleForRowAtIndexPath: which must return a UITableViewCellEditingStyle.

None, delete (red minus), and insert (green plus) are the only options. From the documentation:

Cell Editing Style

The editing control used by a cell.

typedef enum {   
UITableViewCellEditingStyleNone,   
UITableViewCellEditingStyleDelete,   
UITableViewCellEditingStyleInsert  
} UITableViewCellEditingStyle;


You can return as shown in below code

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{  
if(indexPath.row == 0) 
    {

        return  UITableViewCellEditingStyleInsert;
    }
    else
    {
        return UITableViewCellEditingStyleDelete;
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜