旋转后,UISearchBar位于状态栏下方(返回纵向模式)

时间:2019-05-18 13:35:42

标签: ios uinavigationbar uisearchbar uisearchcontroller uistatusbar

重现(仅适用于<= 8的iPhone设备错误,适用于iPhone X *设备正常):

  1. 以纵向模式打开搜索栏(通过单击顶部栏上的搜索项)

@IBAction func onSearchBarItemClicked(_ sender: UIBarButtonItem) { present(searchController, animated: true, completion: nil) }

enter image description here

  1. 将设备旋转到横向位置

enter image description here

  1. 旋转回纵向位置

enter image description here

现在它位于状态栏下方,并且与底部内容重叠

我该如何解决?

UISearchController:

searchController = UISearchController(searchResultsController: nil)
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.keyboardType = UIKeyboardType.asciiCapable
searchController.searchBar.delegate = self

更新

示例项目:https://github.com/anonym24/SearchBarBelowStatusBar/

0 个答案:

没有答案