使用scrolltoindexpath时,Collection View正在跳过一行

时间:2017-06-16 10:06:57

标签: ios objective-c uicollectionview

我正在使用集合视图,我正在尝试使用以下方法在集合视图中进行无限滚动:

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{

    if (infoArray.count-1 == self.indexPathForVisibleCells.row) {

        [self.collection_View scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];    //     [self.collection_View scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]  atScrollPosition:UICollectionViewScrollPositionNone animated:NO];

    }
     }

当我使用这种方法时,当它出现在最后一个单元格然后它移动到索引为1的单元格而不是索引为0的单元格。有人可以解释这种行为并给出一个可能的解决方案吗?

1 个答案:

答案 0 :(得分:0)

你必须试试这个 -

[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]                             atScrollPosition:UICollectionViewScrollPositionTop                                     动画:YES];

更多请参阅以下链接 - http://www.tuicode.com/question/58707ef3c116a36d35c56c21