UICollectionView
でUICollectionViewCell
の高さを設定するときにはcollectionView:layout:sizeForItemAtIndexPath:
を使用しますが、ここでUICollectionViewCell
にUIStackView
が入っている時に高さを設定するにはどうしたら良いでしょうか?
collectionView:layout:sizeForItemAtIndexPath:
でUICollectionViewCell
を呼び出し、UIStackView
を呼び出してcell.containerStackView.frame.size.height
で0が帰ってきます。
Objective
1- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout 2 sizeForItemAtIndexPath:(NSIndexPath *)indexPath { 3 StackCollectionViewCell *cell = (StackCollectionViewCell *)[_collectionView cellForItemAtIndexPath:indexPath]; 4 5 NSLog(@"StackView height %f", cell.containerStackView.frame.size.height); 6 // StackView height 0.0 7 // 実際のStackViewに高さ0ではなく表示されている、このメソッド時には0になる 8 9 return CGSize(320, 80); 10}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/20 01:38 編集
2018/04/20 07:34
2018/04/21 06:44