Reset scroll on UICollectionView

前端 未结 9 1205
太阳男子
太阳男子 2021-01-30 05:25

I have a horizontal UICollectionView which works fine and scrolls. When I tap an item I update my data and call reloadData. This works and the new data

9条回答
  •  攒了一身酷
    2021-01-30 05:36

    Sorry I couldn't comment at the time of this writing, but I was using a UINavigationController and CGPointZero itself didn't get me to the very top so I had to use the following instead.

    CGFloat compensateHeight = -(self.navigationController.navigationBar.bounds.size.height+[UIApplication sharedApplication].statusBarFrame.size.height);
    [self.collectionView setContentOffset:CGPointMake(0, compensateHeight) animated:YES];
    

    Hope this helps somebody in future. Cheers!

提交回复
热议问题