MGSwipeTableCell icon indicating copy to clipboard operation
MGSwipeTableCell copied to clipboard

Delete Tableview Cell when swipe is more that half of screen width

Open Sunitadaffodil opened this issue 9 years ago • 1 comments

Hi,

I am not able to find way of "How to enable delete of row only if user swipe cell more than half of screen width".

I am using this library in one of my project.

Sunitadaffodil avatar Jun 15 '16 09:06 Sunitadaffodil

Hi @Sunitadaffodil

You can do this way. Implement the swipeTableCellWillBeginSwiping delegate method and calculate the expansion threshold based on the buttons width and the UITableView width

-(void) swipeTableCellWillBeginSwiping:(MGSwipeTableCell *) cell
{
    NSArray<MGSwipeButton*> * buttons = cell.rightButtons;
    CGFloat width = 0;
    for (MGSwipeButton * btn in buttons) {
        width += btn.bounds.size.width;
    }

    cell.rightExpansion.threshold = (_tableView.bounds.size.width * 0.5)/width;
}

MortimerGoro avatar Jul 25 '16 10:07 MortimerGoro