我在firstViewController上有一个好看的gridView,并且在SecondViewController上也有UIcollectionview,现在我的问题是,如果我在GridView中选择第四项,那么Collectionview应该显示零项目的第四项内容(现在的集合视图是显示从第0个索引)!
我的didSelectItemAtIndexPath:在FirstViewController上,这里我得到了传递给secondviewcontroller的NSInteger值,
- (void)gridView:(KKGridView *)theGridView didSelectItemAtIndexPath:(KKIndexPath *)indexPath
{
NSInteger globalIndex = ( indexPath.section * numberOfThumbnails ) + indexPath.index;
..............................
}
我的cellForItemAtIndexPath:在secondViewController上,
(UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
itemData =[DataArray objectAtIndex:indexPath.row];
NSString *finalPath = [FileUtils findImagePath:[itemData filename]];
CollectionCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
[cell.imageView setImage:[UIImage imageWithContentsOfFile:finalPath]];
}
答案 0 :(得分:1)
您需要做的是使用
滚动到该特定项目 scrollToItemAtIndexPath:atScrollPosition:animated:
或选择该项目
selectItemAtIndexPath:animated:scrollPosition: