UICollectionView steals focus

I have a UICollectionView with a title, some cells, and optional footer views. The header contains a UISearchBar . If I enter something into the search field, the keyboard will automatically deviate after the first letter. I think this is caused by my -searchBar:textDidChange: which contains the code to update the collection view (via -reloadData , because this is the only method that I know that works).

My theory is that reloading the UICollectionView forces it to become the first responder, but something doesn't work.

I have this line in my release every time the keyboard is rejected:

 setting the first responder view of the collection view but we don't know its type (cell/header/footer) 

I tried to overwrite UICollectionView -canBecomefirstResponder , but unfortunately this did not work.

Any ideas how I can prevent UICollectionView from becoming the first responder after a reboot?

+4
source share
1 answer

I was lucky to restore the search bar as the first responder after updating the table view:

 collectionView.reloadData() searchBar.becomeFirstResponder() 
0
source

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


All Articles