Swipe conflict between a cell and horizontal scroll

ios objective-c uitableview scroll cell

707 просмотра

3 ответа

6286 Репутация автора

Currently I have a horizontal scroll which has several pages inside. Some of these pages have tables with cells that have swipe.

The idea is to be able to swipe the cell and when finished this swipe, somehow activate the scroll swipe to move to the next page. Something like this:

enter image description here

But when I try, it occurs in conflict and 2 scroll at the same time activated. That is while the cell is moving and showing the button, the scroll also begins to move to the other page.

For the swipe cell I'm using SWTableViewCell because the native functionality like the following:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
    }
}

Not even activated, they ignore the swipe of the cell completely and only swipe the scroll is activated.

Thanks, any help would be appreciated.

Автор: jose920405 Источник Размещён: 18.07.2016 05:06

Ответы (3)


2 плюса

155 Репутация автора

try this

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return TRUE;
}
Автор: Deepak Kumar Размещён: 01.08.2016 11:51

0 плюса

2254 Репутация автора

For your horizontal scroll view, have you set the following:

scrollView.cancelsTouchesInView = false

More information on this can be found here: https://developer.apple.com/reference/uikit/uigesturerecognizer/1624218-cancelstouchesinview

Автор: David T Размещён: 01.08.2016 12:01

0 плюса

23 Репутация автора

try this

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    if ([[otherGestureRecognizer.view class] isSubclassOfClass:[UITableView class]]) {
        if ([otherGestureRecognizer isKindOfClass: [UIPanGestureRecognizer class]]) {
            UIPanGestureRecognizer *otherPan = (UIPanGestureRecognizer *)otherGestureRecognizer;
            CGPoint translation = [otherPan translationInView:otherGestureRecognizer.view];
            return translation.x < 0;
        }
    }
    return NO;
}
Автор: Calabash Ball Размещён: 29.10.2017 03:54
Вопросы из категории :
32x32