UIPanGestureRecognizer with TrailingSwipeActionsConfigurationProvider

31 Views Asked by At

The UIViewController has a UIPanGestureRecognizer for a left to right swipe to close the UIViewController. Also in this UIViewController is a UICollectionView which made with the UICollectionLayoutListConfiguration and adds a TrailingSwipeActionsConfigurationProvider. The problem is that the UIPanGestureRecounced for the screen swipe blocks the TrailingSwipeActionsConfigurationProvider actions and they just don't get called. Please tell me how to solve this problem

Creation code configuration.trailingSwipeActionsConfigurationProvider

private func cretaeLayout() -> UICollectionViewCompositionalLayout {
        var configuration = UICollectionLayoutListConfiguration(appearance: .grouped)

        configuration.trailingSwipeActionsConfigurationProvider = { [weak self] indexPath in
            guard let self else { return nil }

            if let item = self.items[safe: indexPath.row] {
                switch item {
                case .common(let viewModel):
                    let actionHandler: UIContextualAction.Handler = { _, _, completion in
                     /// action
                        completion(true)
                    }

                    let action = UIContextualAction(style: .destructive, title: nil, handler: actionHandler)
                    return UISwipeActionsConfiguration(actions: [action])
                case .loading:
                    break
                }
            }

            return nil
        }

        let listLayout = UICollectionViewCompositionalLayout.list(using: configuration)

        return listLayout
    }

How to make sure that gestures are processed at the same time and do not block each other?

0

There are 0 best solutions below