Same code like this
collectionLayout.estimatedItemSize = CGSize(width: 50, height: 25) collectionLayout.itemSize = UICollectionViewFlowLayoutAutomaticSize co
Try this
override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() DispatchQueue.main.async { self.collectionView.collectionViewLayout.invalidateLayout() } }
Adding to viewDidAppear and viewWillAppear will of course work. But viewDidAppear will cause a glitch gor the user.
viewDidAppear
viewWillAppear