After studying for a long time, I found a way to realize the function of nine cells in a very simple way.

The effect is as follows:

Add collectionView to cell. It is not difficult. If there are several pits, it is easy to take a detour.

First of all, the collectionView itself can’t dynamically get the height, so we need to update the height in the set data source method


 [**self**.collectionView reloadData];

Mylog(@"%f",**self**.flowLayout.collectionViewContentSize.height);

[**self**.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {

make.height.equalTo(**self**.flowLayout.collectionViewContentSize.height);

}];

Copy the code

If we directly use Masonry set collectionView, at this time is can’t get to the self. The flowLayout. CollectionViewContentSize. The height of the height, If I navigate to the navigation need, I will see the layout ⚠️.

! The easiest way to do that is to initialize the collectionView and give it a frame, whatever the screen size is.

And then it’s ok.