2015-05-11 8 views

risposta

7

È possibile utilizzare il codice qui sotto per scorrere una UICollectionView di programmazione per il fondo

NSInteger section = [self numberOfSectionsInCollectionView:collectionView] - 1; 
NSInteger item = [self collectionView:collectionView numberOfItemsInSection:section] - 1; 
NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:item inSection:section]; 
[collectionView scrollToItemAtIndexPath:lastIndexPath atScrollPosition:UICollectionViewScrollPositionBottom animated:YES]; 
0

impostare il contentoffset.y dell'oggetto vista della raccolta.

1
NSIndexPath *lastItem = /*Indexpath of last item*/; 
[self.collectionView scrollToItemAtIndexPath:lastItem atScrollPosition:UICollectionViewScrollPositionBottom animated:YES]; 
0

questo codice per Scoll verso il basso.

NSArray *visibleItems = [self.collectionView indexPathsForVisibleItems]; 
    NSIndexPath *currentItem = [visibleItems objectAtIndex:0]; 
    NSIndexPath *nextItem = [NSIndexPath indexPathForItem:currentItem.item + 1 inSection:currentItem.section]; 
    [self.collectionView scrollToItemAtIndexPath:nextItem atScrollPosition:UICollectionViewScrollPositionTop animated:YES];