3

我知道我们可以使用以下方法将集合视图滚动到特定单元格:

[self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionRight animated:NO];

就我而言,我想滚动到包含页脚视图的集合视图的末尾。如果我使用上面的代码,则 UICollectionView 将滚动到最后一个元素,但页脚视图不可见。

4

2 回答 2

1

找到这个答案UIScrollView scroll to bottom programmatically,这对我的collectionview非常有效(尽管对引用答案的争论仍在继续)。

CGPoint bottomOffset = CGPointMake(0, self.collectionView.contentSize.height - self.collectionView.bounds.size.height);
        [self.collectionView setContentOffset:bottomOffset animated:YES];
于 2013-11-25T08:16:05.650 回答
-1

使用以下代码:

   [YourCollectionView setContentOffset:CGPointMake(0, YourCollectionView.contentSize.height) animated:YES];
于 2013-11-25T08:55:24.053 回答