I have some configuration based on the type of data I receive ( the insets to add in the cell.configure(with item: item) {}, however the cells are not re-used properly. I am using RxSwift for binding, though I don't see the issue in there.
tried setting image.layoutMargins = UIEdgeInsets.zero
in prepareForReuse()
, in the cell.configure(with: item)
etc. Doesn't seem to work.
brandsGroup
.bind(to: rx.items(cellIdentifier: StudioCellConstants.brandReuseIdentifier,
cellType: BrandCollectionViewXibCell.self)) { (_, item, cell) in
cell.configure(with: item)
}.disposed(by: disposeBag)
override func prepareForReuse() {
super.prepareForReuse()
image.layoutMargins = UIEdgeInsets.zero
}
Update:
Eventually I ended up setting back the frame like this, but it feels like a hacky solution. A better way would be much appreciated.
image.frame = CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: imageContainerView.frame.width, height: imageContainerView.frame.height)