UICollectionView current visible cell index

后端 未结 16 1424
难免孤独
难免孤独 2020-11-29 16:52

I am using UICollectionView first time in my iPad application. I have set UICollectionView such that its size and cell size is same, means only onc

16条回答
  •  醉梦人生
    2020-11-29 17:24

    Just want to add for others : for some reason, I didnt not get the cell that was visible to the user when I was scrolling to previous cell in collectionView with pagingEnabled.

    So I insert the code inside dispatch_async to give it some "air" and this works for me.

    -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        dispatch_async(dispatch_get_main_queue(), ^{
                UICollectionViewCell * visibleCell= [[self.collectionView visibleCells] objectAtIndex:0];
    
    
                [visibleCell doSomthing];
            });
    }
    

提交回复
热议问题