Ios 返回时,搜索栏将隐藏

Ios 返回时,搜索栏将隐藏,ios,swift,Ios,Swift,我在主页上显示搜索栏。当我按下UIViewController然后返回主页时,搜索栏就会隐藏起来。 这是我的密码 func setupSearch(){ searchController = UISearchController(searchResultsController: resultsTableController) searchController.searchResultsUpdater = self searchController

我在主页上显示搜索栏。当我按下UIViewController然后返回主页时,搜索栏就会隐藏起来。 这是我的密码

func setupSearch(){
        searchController = UISearchController(searchResultsController: resultsTableController)

        searchController.searchResultsUpdater = self
        searchController.searchBar.autocapitalizationType = .none
        searchController.searchBar.searchTextField.placeholder = "Enter a search term...".localized()
        searchController.searchBar.returnKeyType = .search
        
        // Place the search bar in the navigation bar.
        navigationItem.searchController = searchController

        navigationItem.hidesSearchBarWhenScrolling = true
//        searchController.hidesNavigationBarDuringPresentation = false

        // Monitor when the search controller is presented and dismissed.
        searchController.delegate = self

        // Monitor when the search button is tapped, and start/end editing.
        searchController.searchBar.searchTextField.delegate = self

        /** Specify that this view controller determines how the search controller is presented.
            The search controller should be presented modally and match the physical size of this view controller.
        */
        definesPresentationContext = true
    }

您在哪里调用此函数?在viewDidLoad函数中检查此函数。