コレクション ビューで特定のアイテムにスクロールしようとしていますが、約 90% の確率で適切に行われているようです。私は基本的に、自動レイアウトでフレームを変更するコレクションビューを持っています。次に、セルをすべての新しいフレームのサイズにしたいので、新しいサイズを設定します。scrollToItemAtIndexPath にブレークポイントを設定すると、機能するとアイテムのサイズが有効になったように見えますが、機能しない場合、セルはまだ古いサイズのままです。スクロールする前に itemSize が変更されたことを確認するにはどうすればよいですか?
[weakSelf.view removeConstraints:@[weakSelf.verticalSpace, weakSelf.collectionViewBottomSpace, weakSelf.bottomLayoutTopCollectionView]];
[weakSelf.view addConstraints:@[weakSelf.collectionViewToTop, weakSelf.imageHeight, weakSelf.youLabelToTop]];
[UIView animateWithDuration:animated ? .5 : 0.0
animations:^{
[weakSelf.view layoutIfNeeded];
}
completion:^(BOOL finished) {
UICollectionViewFlowLayout * layout = (UICollectionViewFlowLayout *)self.currentUserCollectionView.collectionViewLayout;
layout.itemSize = weakSelf.currentUserCollectionView.frame.size;
[weakSelf.currentUserCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:[self getSelectedIndex:selectItem] inSection:0]
atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally
animated:NO];
}];