Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView被USearchController隐藏_Ios_Swift_Iphone_Navigationbar_Uisearchcontroller - Fatal编程技术网

Ios UIView被USearchController隐藏

Ios UIView被USearchController隐藏,ios,swift,iphone,navigationbar,uisearchcontroller,Ios,Swift,Iphone,Navigationbar,Uisearchcontroller,我正在使用大标题样式的UISearchController。但当我推到下一个视图控制器并再次返回到同一个控制器时,我的UIView被导航栏隐藏 看视频 我无法重现您的错误,但我会发布测试代码,因为它可以帮助您 我建议您在BaseViewController:UIViewController中编写此代码,并在ViewControllers中对其进行扩展,以定义大标题: self.navigationController?.navigationBar.prefersLargeTitles = tr

我正在使用大标题样式的UISearchController。但当我推到下一个视图控制器并再次返回到同一个控制器时,我的UIView被导航栏隐藏

看视频
我无法重现您的错误,但我会发布测试代码,因为它可以帮助您

我建议您在BaseViewController:UIViewController中编写此代码,并在ViewControllers中对其进行扩展,以定义大标题:

 self.navigationController?.navigationBar.prefersLargeTitles = true
定义UISearchController并设置实例

var resultSearchController: UISearchController!

resultSearchController = UISearchController(searchResultsController: nil)
resultSearchController.searchResultsUpdater = self
tableView.tableHeaderView = resultSearchController.searchBar
最后,当屏幕消失时,您可以尝试关闭搜索键盘,如下所示:

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)
    resultSearchController.searchBar.endEditing(true)
}

希望这能有所帮助。

在视图中添加以下行将解决我的问题

extendedLayoutIncludesOpaqueBars = true