当scrollToItemAtIndexPath时,UICollectionView滚出视图

时间:2018-06-09 16:53:04

标签: ios objective-c uicollectionview

我在collectionView中遇到scrollToItem(at:at:animated:)方法时遇到问题。滚动到最后一项时,似乎collectionView滚动出视图。当我在那之后尝试向上滚动时,则collectionView位于底部。

NSInteger section = [self numberOfSectionsInCollectionView:collectionView] - 1;

NSInteger item = [self collectionView:collectionView numberOfItemsInSection:section] - 1;

NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section];

[collectionView scrollToItemAtIndexPath:lastIndexPath atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];

Example Video

0 个答案:

没有答案