Ios UISechController在UICollectionViewController中不工作

Ios UISechController在UICollectionViewController中不工作,ios,iphone,swift,uicollectionview,uisearchcontroller,Ios,Iphone,Swift,Uicollectionview,Uisearchcontroller,我在UICollectionViewController中添加了UISearchController。但当我在搜索栏中输入时,它会关闭键盘。如何将UICollectionViewController中的UISearchController与UISearchResultsUpdate协议一起使用 我试图筛选UICollectionView项目。当我调用self.collectionview.reloadData()时,每个按键上的键盘都会关闭。这是因为调用self.collectionview.r

我在UICollectionViewController中添加了UISearchController。但当我在搜索栏中输入时,它会关闭键盘。如何将UICollectionViewController中的UISearchController与UISearchResultsUpdate协议一起使用


我试图筛选UICollectionView项目。当我调用self.collectionview.reloadData()时,每个按键上的键盘都会关闭。

这是因为调用self.collectionview.reloadData()时 调用所有委托方法,包括ViewForSupplementalElementOfKind,因此您的textfield将退出第一响应者

你可以参考


show,您已经尝试了什么…我将UISearchController添加到UICollectionView的标题中。然后尝试进行实时搜索。当我调用self.collectionView.reloadData()时,键盘将关闭