ios – UICollectionView不能使用UISearchController?

ios – UICollectionView不能使用UISearchController?,第1张

概述在WWDC 2014年的“A Inside Inside Presentation Controllers”中,演示者展示了如何在UITableView中设置UISearchController.他们通过设置searchController的searchBar框架,然后将其设置为tableView的tableHeaderView来实现.不幸的是,UICollectionView没有相当于table 在WWDC 2014年的“A InsIDe InsIDe Presentation Controllers”中,演示者展示了如何在UItableVIEw中设置UISearchController.他们通过设置searchController的searchbar框架,然后将其设置为tableVIEw的tableheaderVIEw来实现.不幸的是,UICollectionVIEw没有相当于tableheaderVIEw.使用UISearchdisplayController,这将很简单:创建一个UISearchbar并将其添加到自定义UICollectionVIEw部分标题中,然后使用搜索栏初始化UISearchdisplayController.问题是,您无法使用UISearchbar初始化UISearchController,甚至可以设置searchbar,因为它是一个只读属性.我想我真正的问题是,我的选择是什么?在没有UISearchdisplayController或UISearchController的情况下是否有实现搜索的“好”方式?解决方法

With UISearchdisplayController,this would be simple: create a UISearchbar and add it to a custom UICollectionVIEw section header,then initialize the UISearchdisplayController with the search bar

UISearchController中的搜索栏是为您创建的.在数据源方法中询问补充视图时

- (UICollectionReusableVIEw *)collectionVIEw:(UICollectionVIEw *)collectionVIEw vIEwForSupplementaryElementOfKind:(Nsstring *)kind atIndexPath:(NSIndexPath *)indexPath

添加searchController.searchbar作为补充视图的子视图.别忘了打电话

[searchController.searchbar sizetoFit]

为了给搜索栏适当的大小.

总结

以上是内存溢出为你收集整理的ios – UICollectionView不能使用UISearchController?全部内容,希望文章能够帮你解决ios – UICollectionView不能使用UISearchController?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1098177.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存