Closed teawithfruit closed 3 years ago
Here's a solution: force the row to resize its self in your reset()
function. Here's how:
row
and form
in your LeadFormularImageCollectionView
class: weak var row: ViewRow<LeadFormularImageCollectionView>? = nil
weak var form: ViewViewController? = nil
<<< ViewRow<LeadFormularImageCollectionView>("LeadFormularImageCollectionView")
.cellSetup { (cell, row) in
cell.view = LeadFormularImageCollectionView()
cell.view!.row = row
cell.view!.form = self
}
reset()
function: func reset() {
print("UIScreen.main.bounds: \(UIScreen.main.bounds)")
let rows:CGFloat = CGFloat(self.data.count) / (CGFloat(UIScreen.main.bounds.size.width) / CGFloat(100))
self.height = CGFloat(rows.rounded(.up)) * 110
print("height: \(self.height)")
// Here I've used https://github.com/layoutBox/PinLayout
self.collectionView!.pin.height(self.height).left(self.pin.safeArea).right(self.pin.safeArea)
self.button.pin.below(of: self.collectionView!).marginTop(10)
self.pin.height(self.height + 60).sizeToFit(.height)
self.frame.size.height = self.height + 60
// Force the row to resize its self.
if let form = form, let row = row { form.tableView.reloadRows(at: [row.indexPath!], with: .none) }
}
Hello. Thanks for publsihing this repo!
I have a question about implementing UICollectionView. First my current code.
The problem is, that the height of the view which holds the UICollectionView have always the wrong height, if I change the device orientation. It seems to me, that the calculation is always one step behind. That means, that your
layoutSubviews
function is faster than mine and that the height of the ViewRow will not fit the content. Do you have an idea to fix that? Or an idea for something I can do to set the right height?How would you implement an UICollectionView with dynamic height?
Thanks