ios - UISearchController 问题
<p><p>我遇到了 UISearchController 的问题。有一些关于 iOS 11 中行为不稳定的报告,但这些建议都没有解决我的问题。</p>
<p>导航栏隐藏在我的应用程序中,所以我只想将搜索栏放在主屏幕上的两个按钮之间。我将 UIView 放在 Storyboard中作为搜索栏的 superView 。当激活结果 Controller 是一个直接的 UITableViewController。 </p>
<p>应用启动时,一切就位。当我访问搜索栏时,它位于屏幕顶部,而将其父 View 留在后面。一切正常,但是当我隐藏表格 View 时,搜索栏实际比它开始时要低一些。这是设置代码:</p>
<pre><code> let locationSearchTable = storyboard!.instantiateViewController(withIdentifier: "LocationSearchTable") as! LocationSearchTable
searchController = UISearchController(searchResultsController: locationSearchTable)
searchController.searchResultsUpdater = locationSearchTable
searchController.delegate = self
locationSearchTable.mapView = mapView
locationSearchTable.handleMapSearchDelegate = self
locationTableController = locationSearchTable
let searchBar = searchController!.searchBar
//searchBar.searchBarStyle = UISearchBarStyle.prominent
searchBar.sizeToFit()
searchBar.placeholder = "Search..."
searchViewHolder.addSubview(searchBar)
searchBar.frame = searchViewHolder.bounds
searchBar.autoresizingMask = [.flexibleWidth, .flexibleHeight]
searchController.dimsBackgroundDuringPresentation = true
definesPresentationContext = false
</code></pre>
<p>我尝试了很多很多方法来解决这个问题。我想知道我是否误解了之前的建议。欢迎任何建议。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我也有同样的问题。如果您的导航栏不是半透明的,请尝试将其放入 viewDidLoad:</p>
<pre><code> extendedLayoutIncludesOpaqueBars = true
</code></pre></p>
<p style="font-size: 20px;">关于ios - UISearchController 问题,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/46596105/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/46596105/
</a>
</p>
页:
[1]