UICollectionViewCell's content misbehaves , the layout animates, when UICollectionView scrolls to the top of the screen.

I am asking here, because it looks like an apple's bug.

looks like squeezed in the following gif, the cell's label laid down.


I solved it by

- (void)viewDidLoad {
    [super viewDidLoad];
     // comment the following line
    // self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

I use UIScrollViewContentInsetAdjustmentNever, to avoid the collectionView's content insets.

Like the following image


In order to keep both, I add one line _collectionView.contentInset = UIEdgeInsetsMake(-20, 0, 0, 0);

Tested on iPhones: iPhone 7 ( 11.4.1 ), iPhone XS Max ( 12.1 )

Any other ideas?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.