2013-09-18 4 views
0

У меня есть хороший вид gridView на firstViewController, а также с UIcollectionview на SecondViewController, теперь моя проблема заключается в том, что если я выберу четвертый элемент в GridView, тогда Collectionview должен показать четвертый item from Zero item (теперь коллекция рассматривается с 0-го индекса)!Как инициализировать uicollectionview с определенным элементом (indexPath)

мой 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]]; 

    } 

ответ

1

Что вы должны сделать либо прокручивается до этого конкретного элемента, используя

scrollToItemAtIndexPath:atScrollPosition:animated: 

Или выберите этот пункт

selectItemAtIndexPath:animated:scrollPosition: 
Смежные вопросы