且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以将 UISearchController 与故事板一起使用吗?

更新时间:2022-06-25 23:57:08

UIView 添加到您的布局.这将是您的 UISearchBar 的容器.然后以编程方式实例化 UISearchController,然后将搜索栏添加到容器中:

Add a UIView to your layout. That will be the container for your UISearchBar. Then programmatically instantiate the UISearchController and then add the searchbar to the container:

let searchController = UISearchController(searchResultsController: searchResultsController)
searchBarContainer.addSubview(searchController.searchBar)