S
S
Shakedown2022-03-26 18:53:32
iOS
Shakedown, 2022-03-26 18:53:32

Why does a cell require a double click in a UICollectionView?

Hello. I have 2 UICollectionView on different controllers which I fill with photos. The code for these collection views is identical (everything is the same in storyboards too), but for some reason, on one controller, the collection view handles clicking on the cell, and on the other controller, you have to make a long or double click on the cell to process the click. Tried debugging, didn't find anything. Also collection views do not overlap other views. What could be the problem?

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return images.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "searchingCell", for: indexPath) as! SearchingCollectionViewCell
        cell.configure(stringUrl: images[indexPath.row].fullUrl)
        
        return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
            collectionView.deselectItem(at: indexPath, animated: true)
            
            let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
            guard let viewController = storyboard.instantiateViewController(withIdentifier:  "DetailImageViewController") as? DetailImageViewController else { return }
            viewController.modalPresentationStyle = .fullScreen
            viewController.wallpaperImage = self?.images[indexPath.row]
            
            self?.present(viewController, animated: true, completion: nil)
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        let frameCollectionView = collectionView.frame
        let cellWidth = frameCollectionView.width / CGFloat(countCells)
        let cellHeight = CGFloat(250)
        
        return CGSize(width: cellWidth - offsetCells, height: cellHeight - offsetCells)
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question