0

我在 firstViewController 上有一个好看的 gridView 并且在 SecondViewController 上有 UIcollectionview,现在我的问题是,如果我在 GridView 中选择第四个项目,那么 Collectionview 应该显示第四个项目而不是零项目(现在 collectionview 从第 0 个开始显示指数) !

我的 didSelectItemAtIndexPath: 在 FirstViewController 上,这里我将 NSInteger 值传递给 secondviewcontroller,

- (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]];

    }
4

1 回答 1

1

您所要做的就是使用滚动到该特定项目

 scrollToItemAtIndexPath:atScrollPosition:animated:  

或选择该项目

 selectItemAtIndexPath:animated:scrollPosition:
于 2013-09-18T11:12:53.123 回答