简体   繁体   中英

Dynamically update uicollectionview cell height

I am working on a quite complicated case

I have a nested UICollectionView The outer UICollectionView A is for vertical scrolling, and it's the first cell, is UICollectionView B, for horizontal scrolling.

It has been implemented perfectly, but now there is one more requirement When scrolling the first cell to the second page, there is one more banner appeared on the bottom of the first cell. Therefore I need to update the height of cell when scrolling.

If I try to call invalid layout when scrolling, it will be very low efficient. Are there any more methods to support it?

黑色容器是垂直集合视图。红色的是水平集合视图。当滚动到第二页时。一个额外的横幅需要动画才能顺利显示

Solved.

First after received the data from the server, each cell height will be calculated and [collectionview reload] will be called.

Then after layouting the collectionview, the size for each cell is cached according to the indexpath.

To implement the 'realtime' resizing, the gesture will call a resizing function directing through a delegate, and directly modify the size cache and call [collectionview.layout invalidlayout].

It looks smooth.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM