Cell content size is changed to the wrong size + cell selection is broken.
Mackarous opened this issue · 2 comments
I was having an issue with cell selection. After the collection view was scrolled, the next visible cell's frame was being changed, and tapping on the cell only successfully called the didSelectItem
function in a much smaller frame than the full cell.
I noticed that this was happening due to the following code:
extension ExpandingViewController {
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let indexPath = IndexPath(row: currentIndex, section: 0)
if case let currentCell as BasePageCollectionCell = collectionView?.cellForItem(at: indexPath) {
currentCell.configurationCell()
}
}
}
When I commented this code out, the collection view cells began to behave properly after scrolling. That is to say, the item selection was happening within the proper bounds, and they were not changed.
I am writing this issue to ask if there was any reason to use the currentCell.configurationCell()
call, since it seems to be manipulating the frames of the cell's view instead of working with auto layout constraints.
I have a fork here with the changes:
https://github.com/Mackarous/expanding-collection/commit/f61c49b41a68d7665e00796142f73d8970bd04cb
+1