cch*_*man 4 nsindexpath ios6 uicollectionview
所以我目前正在开发一个项目,它有一个按钮,可以将单元格添加到UICollectionView,然后需要自动滚动到最后一个单元格(即UICollectionView的底部).
我找到了这个方法
scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated
但现在我陷入了试图找到indexPathCollectionView中最后一个对象的问题.
问题似乎在于我一直在试图将UICollectionView中的单元格视为一个数组(不能通过它们枚举,不响应lastObject等等).我似乎可以得到最接近的是方法,visibleItems这确实给我一个数组但是当我需要那些可见帧的外细胞加入于事无补.
有没有办法在CollectionView中获取最后一个对象的IndexPath?
Tim*_*ose 15
你可以问你的数据来源:
NSInteger section = [self numberOfSectionsInCollectionView:self.collectionView] - 1;
NSInteger item = [self collectionView:self.collectionView numberOfItemsInSection:section] - 1;
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7980 次 |
| 最近记录: |