betzerra/EBCardCollectionViewLayout

How to determine which cell is currently displayed on the screen in the middle?

Closed this issue · 2 comments

How to determine which cell is currently displayed on the screen in the middle?

P.S: Thank you for good layout!! I use it in my project.

Decided so (but that crutch):

  • (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
    cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    ... code ...
    [self currentVisibleUser];
    }

-(void)currentVisibleUser{

CGPoint center = CGPointMake(self.collectionView.bounds.origin.x+self.collectionView.center.x/2, self.collectionView.center.y/2);
NSIndexPath *path =[self.collectionView indexPathForItemAtPoint:center];
... my code ...

}

@SadhuRus EBCardCollectionViewLayout has a currentPage property :-)

@property (readonly) NSInteger currentPage;