         
         if self.imagePickerController.allowSwipeToSelect {
             let swipeOutGesture: UIPanGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.swiping(gesture:)))
+            swipeOutGesture.delegate = self
+            self.collectionView.panGestureRecognizer.require(toFail: swipeOutGesture)
             self.collectionView.addGestureRecognizer(swipeOutGesture)
         }
     }

                self.imagePickerController.presentCamera()
            }
        } else {
            selectAsset(atIndex: indexPath)
        }
    }
    
    public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
        
        if let removedAsset = (collectionView.cellForItem(at: indexPath) as? DKAssetGroupDetailBaseCell)?.asset {
            let removedIndex = self.imagePickerController.selectedAssets.index(of: removedAsset)!
            
            /// Minimize the number of times.
            let indexPathsForSelectedItems = collectionView.indexPathsForSelectedItems!
            let indexPathsForVisibleItems = collectionView.indexPathsForVisibleItems
            
            let intersect = Set(indexPathsForVisibleItems).intersection(Set(indexPathsForSelectedItems))
            
            for selectedIndexPath in intersect {
                if let selectedCell = (collectionView.cellForItem(at: selectedIndexPath) as? DKAssetGroupDetailBaseCell), let selectedCellAsset = selectedCell.asset, let selectedIndex = self.imagePickerController.selectedAssets.index(of: selectedCellAsset) {
                    if selectedIndex > removedIndex {
                        selectedCell.index = selectedCell.index - 1
                    }
                }
            }
            
            self.imagePickerController.deselectImage(removedAsset)
        }
    }
    
    public func scrollViewDidScroll(_ scrollView: UIScrollView) {


        if let index = self.imagePickerController.selectedAssets.index(of: asset) {
			cell.isSelected = true
			cell.selectedIndex = selectedIndex
			self.collectionView!.selectItem(at: indexPath, animated: false, scrollPosition: [])
		} else {
			cell.isSelected = false
