0

I added swipe to delete optionality to a table view cell by implementing

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Perform the real delete action here. Note: you may need to check editing style
    //   if you do not perform delete only.
    NSLog(@"Deleted row.");
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete;
}

This is resulting in my table loading in such a way that a delete button is immediately displayed on the left. I only want a swipe to delete option, I don't want any delete button showing when the table first loads. What do I need to change?

enter image description here

helloB
  • 3,472
  • 10
  • 40
  • 87
  • http://stackoverflow.com/a/3309737/192976 – Hons Dec 13 '16 at 19:48
  • Possible duplicate of [UITableViewCell, show delete button on swipe](http://stackoverflow.com/questions/3309484/uitableviewcell-show-delete-button-on-swipe) – Ryan H. Dec 13 '16 at 19:49

1 Answers1

0

Remove the second function (editingStyleForRowAtIndexPath), and change the first one to the one below:

 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
        if (editingStyle == UITableViewCellEditingStyleDelete) {
            //add code here for when you hit delete
        }    
    }
cpatmulloy
  • 197
  • 9