Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView always auto sizing cells. Not using sizes returned from delegate

Recently upgraded to Xcode 11 / iOS13. Working on a new view controller. The UICollectionView is calling my sizeForItemAtPath delegate method, but it seems like the collection view is always choosing self sizing based on constraints. But I don't want it to!

I tried setting the estimatedSize to 1x1 just to try and work around this. Didn't work. I've breakpointed on all the delegate / datasource methods and don't see anything out of the ordinary.

I also came across this (`systemLayoutSizeFittingSize` not called on iOS 13), maybe my issue is related? I am able to fix the issue by overriding the systemFittingSize method in that link - but I really shouldn't have to.

The odd thing I find is that any existing xibs with collection views are working as expected - the only difference seems to be me creating the cell / collection view with Xcode 11 VS Xcode 10.

I also noticed that UICollectionViewCell elements in Xcode11 contain a "Content View" - but Xcode 10 xibs don't have a Content View.

Anyone else experience this?

like image 383
gngrwzrd Avatar asked Oct 06 '19 23:10

gngrwzrd


1 Answers

There's a setting in interface builder for estimated size - set it to None.

enter image description here

Change to None:

enter image description here

like image 77
gngrwzrd Avatar answered Oct 21 '22 22:10

gngrwzrd