UICollectionView, full width cells, allow autolayo

2019-01-30 06:28发布

Here's a fairly basic question about current iOS development, to which I've never found a good answer.


In a (say) vertical UICollectionView ,

Is it possible to have full-width cells, but, allow the dynamic height to be controlled by autolayout?

(If you're new to iOS "dynamic height", meaning the cell has a few, say, text views which could be any length or images which could be different sizes, so ultimately each cell is a totally different height.)

If so how?

This strikes me as perhaps the "most important question in iOS with no really good answer."

13条回答
啃猪蹄的小仙女
2楼-- · 2019-01-30 07:02

From iOS 10, we've got new API on flow layout to do that.

All you have to do is set your flowLayout.estimatedItemSize to a new constant, UICollectionViewFlowLayoutAutomaticSize.

Source: http://asciiwwdc.com/2016/sessions/219

查看更多
登录 后发表回答