I've added a UISearchBar
to a UICollectionView
and in the delegate searchBar:textDidChange:
filter my model and call [collectionView reloadData]
. reloadData
(as well as reloadSection, etc) wants to take away firstResponder from the searchbar's textfield, thus dismissing the keyboard.
I am trying to build a "live updating" filter and so it's annoying to have the keyboard go away after each character typed.
Any ideas?
I've just created a small test application. The following code does not hide the keyboard on entering characters in the searchbar. That said, [UITableView reloadData] does not resign the responder.
Are you sure, you're not resigning it somewhere?
In searchBar delegate function , I use performBatchUpdates, first,reload collectionView then call [self.searchBar becomeFirstResponder] to display keyboard
I think you are calling the
-resignFirstResponder
method in the searchbar delegate which cause every time you enter the value it gets dismissedYou are in the right path about the datasource methods and reload data.Use an array to store all values another array for loading the collectionview and on every letter entered on the search bar filter and load the datasource array and then reload
Well i think it is better to keep the keyboard .That is the right UI style after you are done entering the text to search you can dismiss it manually.I think it is the better option for a live updating filter.
If you are using a button to search then you can include the keyboard hide option there.but the live update cannot be implemented when using such an option