0

i'm using tableview with two actions, delete and edit. when i swipe to show the action the first one returned in the array of editActionsForRowAtIndexPath: is called automatically

-(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {

     UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
                                      {
                                         // delete ...
                                      }];

     deleteAction.backgroundColor = [UIColor redColor];

     UITableViewRowAction *edit = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"  Edit  " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath)
                              {
                                   // edit ...
                              }];
     edit.backgroundColor = [UIColor colorWithRed:0x2F/255.0 green:0x83/255.0 blue:0xFB/255.0 alpha:1];    

     return @[deleteAction,edit];
}

here the delete action is called. I want the actions to show when swipe but not to be called without tapping.

1 Answers1

0

For this you need to swipe table row slightly.Then it will show both the action options and actions will be called on tapping only.

Mangesh Murhe
  • 361
  • 1
  • 8
  • 1
    is there a solution to prevent the call on swipe? – Mohamed Kammoun Nov 21 '17 at 12:22
  • No. Because on full swipe the first action is being called by default by the swipe gesture. You can edit the sequence of actions as per your convenience. For example:- return @[edit,deleteAction]; . So on every full swipe of cell edit action will get called instead of delete action. – Mangesh Murhe Nov 22 '17 at 06:16
  • You can do it with Swift. Simply implement trailingSwipeActionsConfigurationForRowAt instead of editActionsForRowAtIndexPath. See this answer for more details: https://stackoverflow.com/a/46417015/5758986 – Kevin LeStarge Jul 29 '19 at 16:22