I am trying to implement "swipe to delete" functionality in a uitableview. I have followed other tutorials/forums and extended UITableViewSource. Within that class I have overridden the following methods:
public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
{
if (editingStyle == UITableViewCellEditingStyle.Delete)
{
tableItems.RemoveAt(indexPath.Row);
tableView.DeleteRows(new [] { indexPath }, UITableViewRowAnimation.Fade);
}
}
public override UITableViewCellEditingStyle EditingStyleForRow(UITableView tableView, NSIndexPath indexPath)
{
return UITableViewCellEditingStyle.Delete;
}
public override bool CanEditRow(UITableView tableView, NSIndexPath indexPath)
{
return true;
}
I believe these are the only methods I should need. However when I perform a swipe gesture, the CanEditRow and EditingStyleForRow methods are called but CommitEditingStyle is never called. Any help would be much appreciated. Thanks.