我尝试将搜索栏添加到带有标识符的单元格中,并使用此方法 viewForHeaderInSection
出现错误
The search bar outlet from the UISearchController to the UISearchBar. Outlet cannot be connected to repeating content.
所以基本上我想让搜索栏在滚动表格 View 时保持不变。这是我让它起作用的方法,但它不起作用。
有什么建议吗?
最佳答案
如果你希望它总是在顶部可见,你也可以将搜索栏放在导航栏(导航 Controller )的导航栏中作为它的标题 View 。
self.navigationItem.titleView=self.searchController.searchBar;
为了让它适应所有方向的屏幕,只需添加以下内容:
[self.searchController.searchBar sizeToFit];
希望对您有所帮助:)
关于ios - 如何在标题中制作搜索栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31980075/