priore

Correct way for to scroll after of reloadData completion

Feb 9th, 2016
675
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // correct way for to scroll, or execute a block of code, only after of reloadData completion
  2. [self.collectionView reloadData];
  3. [[NSOperationQueue mainQueue] addOperationWithBlock:^{
  4.     // scroll to item
  5.     NSIndexPath *indexPath = [NSIndexPath indexPathForItem:3 inSection:0];
  6.     [self.collectionView selectItemAtIndexPath:indexPath animated:YES scrollPosition:UICollectionViewScrollPositionLeft];
  7. }];
RAW Paste Data