4

i want to add custom EditingAccessoryView in cell, when user swipe in place of delete button i want to show my custom view.

priyanka
  • 2,076
  • 1
  • 16
  • 20
  • Are you able to show the indicator button in cell when the tableView is in Editing mode showing after pressing the RED Delete button ? – Ajay Sharma Sep 06 '11 at 07:21

2 Answers2

2

There doesn't seem to be a function for that. All you can do is give a custom text for the Delete confirmation button, by using the function below.

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
Anand V
  • 423
  • 3
  • 13
  • thanks. but i want to add two buttons in place of one delete button. don't want to change title of that button – priyanka Nov 10 '10 at 09:24
  • This is exactly what I was trying to figure out how to do. Sorry, I won't upvote because it didn't address the question asked. But thanks! – androidnotgenius Feb 03 '14 at 15:55
0

Design view from xib like bellow example

alt text

now make IBOutlet of uiview in .h file

IBOutlet UIView *accessoryView;

connect that IBOutlet to your design view.

now in .m file set that view as editingAccessoryView of table cell

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        cell.editingAccessoryView = accessoryView;

       }

}


- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

   return NO;

}

now when you swipe your custom view will show in place of delete button

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
priyanka
  • 2,076
  • 1
  • 16
  • 20
  • I'm likewise trying to do this at the moment, EightyEight, and finding this solution - that I presumed would be about right - doesn't work under iOS 6 (simulator, on XCode 5 beta). – Slowburner Jul 29 '13 at 10:11
  • 1
    This doesn't work at all. First of all, returning NO for "canEditRowAtIndexPath" will simply prevent the editingAccessoryView from showing up at all. Second problem is that you need to instantiate a new instance of the accessory view for every new cell. Last of all ... I don't think "dequeueReusableCellWithIdentifier" ever returns nil, which of course means that the editingAccessoryView will never be assigned. Did you actually test this code? I really don't think so. – Owen Godfrey Sep 25 '13 at 16:48