UISeachcontroller does not work in UICollectionViewController

I added a UISearchController to the UICollectionViewController. But when I type in searchBar, it rejects the keyboard. How can I use the UISearchController in a UICollectionViewController with the UISearchResultsUpdating protocol.

I tried to filter the search by UICollectionView elements. When I call self.collectionview.reloadData (), on every keystroke, the keyboard is rejected.

+5
source share
1 answer

This is because when you call self.collectionView.reloadData () all the delegate methods, including viewForSupplementaryElementOfKind, so your text box will put up with the first responder.

you can refer

CollectionViewWithSearchBar

+2
source

Source: https://habr.com/ru/post/1275731/


All Articles