UISearchController 模态存在时的不正确行为

UISearchController incorrect behavior when it is present modally

我展示了 UIViewController 模态风格。 UIViewControllerUITableView。我将 UISearchController 添加到 UITableView,但 UISearchController 在消失时出现了不正确的行为。我做了很多次 UISearchControllers 但我没有遇到这种行为。

我的代码

所以我显示 UIViewController

 @objc fileprivate func selectInterlocutor(_ button: UIButton) {
        let selectInterlocutorTVC = SelectInterlocutorTableViewController()
        selectInterlocutorTVC.modalPresentationStyle = .overCurrentContext
        selectInterlocutorTVC.modalTransitionStyle = .coverVertical
        selectInterlocutorTVC.providesPresentationContextTransitionStyle = true
        present(selectInterlocutorTVC, animated: true) {

        }
    }

我把UISearchController加到tableView

  fileprivate func addSearchController() {
        searchController.searchBar.barStyle = .default
        searchController.delegate = self
        searchController.searchBar.delegate = self
        searchController.searchResultsUpdater = self
        searchController.searchBar.autocapitalizationType = .words
        searchController.dimsBackgroundDuringPresentation = false
        searchController.hidesNavigationBarDuringPresentation = false
        searchController.searchBar.sizeToFit()

        tableView.tableHeaderView = searchController.searchBar
    }

请观看此视频,了解此行为。 https://www.dropbox.com/s/l3m3q8wmqoy3qv2/SearchBarBug.mov?dl=0

我该如何解决?

我删除了 UISearchController 并使用了 UISearchBar,它对我有用。

 fileprivate func addSearchController() {
        searchBar.barStyle = .default
        searchBar.delegate = self
        searchBar.autocapitalizationType = .words
        searchBar.showsCancelButton = true
        searchBar.sizeToFit()

        tableView.tableHeaderView = searchBar
    }