2016-08-01 11 views

Antwort

1

Versuchen Sie, die unter Methode der Verwendung UICollectionViewDelegate:

- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated; 

params-

indexPath: index Pfad der Zelle

animiert: Ja/Nein.

scrollPosition: Position der Zelle beim Scrollen. Wählen Sie aus folgenden Optionen:

Vertikal

UICollectionViewScrollPositionTop     
UICollectionViewScrollPositionCenteredVertically 
UICollectionViewScrollPositionBottom 

Horizontal Positions-

Positions-
UICollectionViewScrollPositionLeft 
UICollectionViewScrollPositionCenteredHorizontally 
UICollectionViewScrollPositionRight 
1

Setzen Sie zunächst eine Instanzvariable, um anzugeben, dass die Zelle ausgewählt werden soll.

self.selectedIndexPath = indexPath; 

nächstes Blättern zu der Zelle unter Verwendung von:

[_calendarView scrollToItemAtIndexPath:indexPath atScrollPosition: UICollectionViewScrollPositionNone animated:YES]; 

Wenn eine Zelle aus collectionView:cellForItemAtIndexPath: Rückkehr in die Instanzvariable zu vergleichen. Wenn Sie eine Übereinstimmung haben, wählen Sie die Zelle aus und legen Sie die Instanzvariable auf fest.