Answer the question
In order to leave comments, you need to log in
Why is the size of the items in the collectionview displayed incorrectly when I change from portrait to landscape view?
There is a tabBar that is made in the form of a collectionview with 4 items, the size of the items is determined by:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: frame.width/4, height: frame. height) }
But when I set the view they change in size i.e. as far as I understand, the size is not recalculated How to fix it
Answer the question
In order to leave comments, you need to log in
override func viewWillLayoutSubviews() {
tabBar.collectionTab.collectionViewLayout.invalidateLayout()
}
This thing helped
Probably the frame variable has not updated its data. What does the debugger say?
---
how to check? - put a breakpoint on the line return CGSize(width: frame.width/4, height: frame.height) ; when it stops - look in the list of variables what is the value of the variable
how to update? Is there a screen rotation tracking method? Let me look for you
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question