关于 UICollectionView 的一个问题。UICollectionView 嵌套在 UITableViewCell 中。问题就是以下一段简单的代码,但是线上 [self.feed.blog.imageInfos objectAtIndex:indexPath.row] 这里经常出现数组越界,很奇怪!! indexPath 的 bound 不是上面的 collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 这个函数约束了吗,为什么会越界。
- (NSInteger)collectionView:(UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section {
return count = self.imageInfos.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
LKMImageInfo *imageInfo = [self.imageInfos objectAtIndex:indexPath.row];
...
return imageCell;
}