         case .possible:
             break
         case .began:
-            if let indexPath = self.collectionView.indexPathForItem(at: location)
-                , let cell = self.collectionView.cellForItem(at: indexPath) {
+            if let indexPath = collectionView?.indexPathForItem(at: location)
+                , let cell = collectionView?.cellForItem(at: indexPath) {
                 self.fromIndexPath = indexPath
                 self.swipingToSelect = !cell.isSelected
             }

        }
        assetIndex = (index - (self.hidesCamera ? 0 : 1))
        
        guard let group = self.imagePickerController.groupDataManager.fetchGroup(with: selectedGroupId) else {
            assertionFailure("Expect group")
            return nil
        }
        return self.imagePickerController.groupDataManager.fetchAsset(group, index: assetIndex)
    }
    
    // select an asset at a specific index
    public func selectAsset(atIndex indexPath: IndexPath) {
        guard let cell = self.collectionView.cellForItem(at: indexPath) as? DKAssetGroupDetailBaseCell
            , let asset = cell.asset else {
            return
        }
        
        if !self.imagePickerController.contains(asset: asset) {
            self.imagePickerController.select(asset: asset)
        }
    }
    
    public func deselectAsset(atIndex indexPath: IndexPath) {
        guard let cell = self.collectionView.cellForItem(at: indexPath) as? DKAssetGroupDetailBaseCell
            , let asset = cell.asset else {
                return
        }

        self.imagePickerController.deselect(asset: asset)
    }
    
    public func adjustAssetIndex(_ index: Int) -> Int {

    }
    
    @objc private func autoScrolling() {
        guard let collectionView = collectionView else {
            assertionFailure("Expect collectionView")
            return
        }

        let offsetY = CGFloat(self.autoScrollingDirection == .down ? self.autoScrollingRate : -self.autoScrollingRate)
        
        var targetContentOffset = collectionView.contentOffset
        targetContentOffset.y += offsetY
        
        targetContentOffset.y = min(max(targetContentOffset.y, collectionView.contentInset.top),
                                    collectionView.contentSize.height - collectionView.bounds.height)
        
        collectionView.contentOffset = targetContentOffset
        
        onSwipingChanged(location: CGPoint(x: self.swipingLastLocation.x,
                                           y: self.swipingLastLocation.y + offsetY))
    }
    
    // MARK: - UIGestureRecognizerDelegate
