我想获取 uicollectionview 的最后一个索引路径。
我试过这个:
NSInteger section = [self numberOfSectionsInCollectionView:self.collectionView] - 1;
NSInteger item = [self collectionView:self.collectionView numberOfItemsInSection:section] - 1;
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section];
但是找不到 uicollectionview 的最后一个索引路径。
任何建议, 提前致谢。
最佳答案
NSInteger lastSectionIndex = [tableView numberOfSections] - 1;
NSInteger lastRowIndex = [tableView numberOfRowsInSection:lastSectionIndex] - 1;
// Now just construct the index path
NSIndexPath *pathToLastRow = [NSIndexPath indexPathForRow:lastRowIndex inSection:lastSectionIndex];
关于ios - 如何获取 uicollectionview 的最后一个索引路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28615052/