Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collection View items do not appear when user is on a call

I have a collection view. When I toggle the in-call status bar, my collection view items disappear when the green "you are on a call" status bar is visible. They return when I dismiss the bar.

The log spits out this: "The behavior of the UICollectionViewFlowLayout is not defined because the item height must be less that the height of the UICollectionView minus the section insets top and bottom values."

Has anyone encountered this, and how have you gotten around it? I am using sizeForItemAtIndexPath as follows:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return self.collectionView.frame.size;
}

Should I be using something else to specify the size of each item?

like image 542
RyJ Avatar asked Jan 17 '26 05:01

RyJ


1 Answers

For anyone else that experiences this. This is the right way to define the item size:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return self.collectionView.frame.size;
}

You could probably also set itemSize on the collectionViewLayout, but the key to making the items stick around, and not disappear when on a phone call, is to reload the collection view in viewDidLayoutSubviews:

[self.collectionView reloadData];
like image 196
RyJ Avatar answered Jan 19 '26 19:01

RyJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!