在我们的项目中,我们指定
hidesNavigationBarDuringPresentation = false
关于特定UIViewController
的UISearchController
。searchController 有一个范围标题数组。到目前为止,这在 iOS 10 上运行良好,但在 iOS 11 测试版中,看起来 hidesNavigationBarDuringPresentation 的错误设置被忽略并扰乱了我们的显示。为了确保它不是因为我的项目中的其他因素,我创建了一个只有一个的准系统测试项目UITableViewController
,并UISearchController
用另一个简单的UITableViewController
. 以下代码在viewDidLoad()
主视图控制器的方法中:
self.title = "Search Bar Scope Test"
let searchViewController = SearchViewController(style: .plain)
searchController = UISearchController(searchResultsController: searchViewController)
searchController!.searchBar.sizeToFit()
tableView.tableHeaderView = searchController!.searchBar
searchController?.hidesNavigationBarDuringPresentation = false
searchController?.searchBar.scopeButtonTitles = ["scope 1", "scope 2", "scope 3", "scope 4", "scope 5"]
当最后一行分配scopeButtonTitles
不存在时,导航栏不会隐藏,搜索栏保持在其原始位置。但是,在存在该行的情况下,iPhone 和 iPad 上的竖屏模式和加号范围按钮都NavigationBar
被隐藏了searchBar
,但在横屏模式下保持不变(即使范围按钮很多并且不能放在一个线)。
有没有其他人遇到过这个?这是 iOS 11 中的错误或预期行为(当然不是我们想要的行为),是否有任何解决方法?
谢谢!