【发布时间】:2018-09-18 13:59:15
【问题描述】:
我正在以编程方式进行。我也尝试将其设置为 TitleView,但它不起作用。 代码如下:
//searchBar
let searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search Players"
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
definesPresentationContext = true
我在 searchBar 下也有一个 ScopeBar,当被选中时。 如果我这样做:
searchController.titleView = searchController.searchBar
它就位,但我无法再选择/点击搜索栏。
【问题讨论】:
-
如果要实现搜索建议使用
UISearchController,否则使用普通UISearchBar -
你可能想看看这个问题,它是相应的答案。 stackoverflow.com/questions/38589999/…
标签: ios swift uitabbarcontroller navigationitem