0
我有一個全屏的collectionView視圖,他的單元格也是全屏的;一個單元格一次可見(讓我們假設它只是簡單的iPhone 5)。在下面的代碼我記錄哪個小區被加載:CollectionView中的日誌單元格
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCell" forIndexPath:indexPath];
NSObject *someObject = [someArray objectAtIndex:indexPath.row];
cell.someLabel.text = [someObject valueForKey:@"label"];
NSLog(@"index:%d",[someArray indexOfObject:someObject]);
}
當我滾動甚至一個像素向下(在的CollectionView垂直滾動),則移動index:
從0
到1
。當我向後滾動同一像素時,它仍會讀取1
。顯然,向下滾動一個像素只會顯示第二個單元格的一個像素,它會被記錄下來。向後滾動顯示整個第一個單元格,但不記錄0
。
如何記錄當前哪個單元格完全位於視圖中?