SectionInset does not work with UICollectionView estimated ITemSize in iOS8 using AutoLayout

I cannot get my UICollection to set the sectionInset.left marker sectionInset.left when using boxes with estimatedItemSize sizes. UICollectionview cells must have some fixed cell height, but dynamic width according to the length of the text.

Here's what it looks like when self-learning mode is turned on:

enter image description here

And when self-limiting is turned off:

enter image description here

Oddly enough, it seems that sectionInset.right working, i.e. the field is added on the right side of the UICollectionView.

Here is my custom UICollectionViewFlowLayout, I switch the self-size mode using a comment.

 class myFlow: UICollectionViewFlowLayout { required init(coder: NSCoder) { super.init(coder: coder) self.minimumLineSpacing = 1 // self.estimatedItemSize = CGSize(width: 100, height: 35) self.sectionInset.left = 20 } 

And my custom UICollectionView:

 class myCV: UICollectionView { required init(coder decoder: NSCoder) { super.init(coder: decoder) self.layer.cornerRadius = 5.0 self.layer.borderWidth = 1.0 self.layer.borderColor = UIColor.lightGrayColor().CGColor } } 

I laid out a shortcut inside a UICollectionView cell using AutoLayout:

enter image description here

+5
source share
1 answer

I found work around this - use the contentInset property of the UIScrollView , i.e. the superclass of UICollectionView . Strictly speaking, this is the answer, but at least the solution to the problem

0
source

All Articles