I followed UICollectionView reloadData resigns first responder in section header to implement search bar on collectionview, but when collectionView?.reloadData()
is called, the screen below is shown and i've to scroll down to find the filtered cells.
My code for datasource
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 2
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return section == 0 ? 0 : count // this got called after reloadData
}
override func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(...)
// this function did not get called after reloadData
}