Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.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 搜索栏在滚动中消失,如何防止此操作_Ios_Swift - Fatal编程技术网

Ios 搜索栏在滚动中消失,如何防止此操作

Ios 搜索栏在滚动中消失,如何防止此操作,ios,swift,Ios,Swift,我的搜索栏在滚动时似乎消失了,即使我正在使用 navigationController?.hidesBarsOnSwipe = false 下面也使用 navigationItem.searchController = searchController 无效 似乎没有任何效果,我为搜索控制器添加的代码是 searchControlInstance = UISearchController(searchResultsController: nil) searchC

我的搜索栏在滚动时似乎消失了,即使我正在使用

navigationController?.hidesBarsOnSwipe = false
下面也使用

navigationItem.searchController = searchController
无效

似乎没有任何效果,我为搜索控制器添加的代码是

searchControlInstance = UISearchController(searchResultsController: nil)
      
        searchControlInstance.searchResultsUpdater = self
        searchControlInstance.obscuresBackgroundDuringPresentation = false
       
        self.definesPresentationContext = true
        searchControlInstance.searchBar.returnKeyType = .done
        navigationItem.hidesSearchBarWhenScrolling = false
我确实有

navigationController?.navigationBar.prefersLargeTitles = true

但将其设置为false似乎没有任何效果搜索栏就像图中一样消失了,我在哪里犯了错误,有人能建议,我不使用故事板吗

navigationItem.searchController = searchControlInstance
navigationItem.hidesSearchBarWhenScrolling = false

您必须这样设置:

navigationItem.searchController = searchControlInstance
navigationItem.hidesSearchBarWhenScrolling = false

是的。。您需要同时设置:)我得到了相同的结果,我在回答中提到了这一点,谢谢任何其他需要添加内容的设置?嗯,我想您没有同时尝试这两种设置。嘿,成功了,我需要禁用navigationController?.hidesBarsOnSwipe=true,谢谢。。您需要同时设置:)我得到了相同的结果,我在回答中提到了这一点,谢谢任何其他需要添加内容的设置?嗯,我想您没有同时尝试这两种设置。嘿,成功了,我需要禁用navigationController?.hidesBarsOnSwipe=true,谢谢