6

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.

Marco Mustapic
  • 3,879
  • 1
  • 21
  • 20

2 Answers2

7

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;
NSResponder
  • 16,861
  • 7
  • 32
  • 46
gerry3
  • 21,420
  • 9
  • 66
  • 74
  • 7
    By the way — these is a third option called "multi-select" with editingStyle = 3. This is an **undocumented** feature. – kennytm Jan 14 '10 at 05:48
  • I guess I'll have to resize the cell's subviews myself then. – Marco Mustapic Jan 14 '10 at 14:06
  • 1
    Gah, that undocumented option would be perfect for us. Search on the iOS dev forums for uitableview with multi row selection for the official answer on this: don't use. Grrr. – MrCranky Oct 21 '10 at 13:26
  • 2
    Check out the _Table View Multi-Row Edit Mode_ blog post from Jeff LaMarche: http://iphonedevelopment.blogspot.com/2008/10/table-view-multi-row-edit-mode.html – gerry3 Nov 03 '10 at 01:31
1

You can return as shown in below code

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

        return  UITableViewCellEditingStyleInsert;
    }
    else
    {
        return UITableViewCellEditingStyleDelete;
    }
}
Kamleshwar
  • 2,967
  • 1
  • 25
  • 27