iOS --网格UICollectionView第一次加载设置位置不顶用的解决方法

[self.view layoutIfNeeded];

    NSIndexPath *path=[NSIndexPath indexPathForItem:self.index inSection:0];

    [_collectionView scrollToItemAtIndexPath:path atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO];

注意:一定要加上layoutIfNeeded

猜你喜欢

转载自blog.csdn.net/qq_27979381/article/details/81206584