【发布时间】:2015-02-19 19:21:39
【问题描述】:
我想获取 uicollectionview 的最后一个 indexpath。
我试过了:
NSInteger section = [self numberOfSectionsInCollectionView:self.collectionView] - 1;
NSInteger item = [self collectionView:self.collectionView numberOfItemsInSection:section] - 1;
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section];
但找不到 uicollectionview 的最后一个索引路径。
任何建议, 提前致谢。
【问题讨论】:
-
代码看起来没问题。 “找不到 uicollectionview 的最后一个索引路径”是什么意思?
NSLog(@"%@", indexPath)的输出是什么?预期的输出是什么? -
NSInteger section = [_collectionView numberOfSections] - 1 ; NSInteger item = [_collectionView numberOfItemsInSection:section] - 2 ; NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section] ;这对我来说很好......感谢您的评论
-
你为什么不从你的 model 创建索引路径呢?这样会感觉更自然,而不是弄乱 view。
标签: ios uicollectionview nsindexpath