how can i see where a cell is located by clicking on collectionview?

Using whichever variable you assigned to your collection view, I normally access it using something like this in my viewDidLoad:

myCollectionView.rx.itemSelected
    .subscribe(onNext: { [weak self] indexPath in
        let cell = self?.myCollectionView.cellForItem(at: indexPath)
        // Perform your animation operations here
    }).diposed(by: disposeBag)

Based on your example, you can use the same idea and access your cell using the cellForItem(at:) function:

Observable.zip(myCollectionView.rx.itemSelected, myCollectionView.rx.modelSelected(RecipesCollectionViewCellViewModel.self))
    .bind { indexPath, model in
        let cell = self?.myCollectionView.cellForItem(at: indexPath) as? MyCollectionViewCell
}.disposed(by: disposeBag)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top