I'm using collection view in side UITableViewCell, on reload
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
guard let _cell = cell as? BrandRow else { return }
let _flow = columnLayout
_flow.scrollDirection = .horizontal
_cell.collectionView.collectionViewLayout = _flow
_cell.collectionView.delegate = self
_cell.collectionView.tag = indexPath.section
_cell.collectionView.dataSource = self
_cell.collectionView.showsVerticalScrollIndicator = false
_cell.collectionView.showsHorizontalScrollIndicator = false
_cell.collectionView.reloadData()
}
In iPhone 6 while cell get reused it crashes my app
_cell.collectionView.reloadData()
can anyone please let me know what's wrong with my code?
Error
question from:https://stackoverflow.com/questions/65936584/application-crash-in-iphone-6-while-reloaddataAssertion failure in -[UICollectionViewData validateLayoutInRect:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3698.140/UICollectionViewData.m:447
2021-01-28 17:10:08.921104+0500 Okayhai[630:48362] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xec57a98e0a4dfaae> {length = 2, path = 0 - 4}'