单击搜索栏时如何修复跳转?

How to fix jump when click on search bar?

点击搜索栏出现跳转现象

视图如下。

https://i.imgur.com/reKZ1wA.gif


我的代码。

lazy var searchController: UISearchController = {
    let searchController = UISearchController(searchResultsController: nil)
    searchController.searchBar.placeholder = "Search"
    searchController.hidesNavigationBarDuringPresentation = false
    searchController.searchResultsUpdater = self
    searchController.searchBar.delegate = self
    return searchController
}()

func setUpNavigationItem() {
    navigationItem.title = "Search"
    navigationItem.searchController = searchController
    navigationItem.hidesSearchBarWhenScrolling = true

    let loginButton = UIBarButtonItem(title: "Login", style: .plain, target: nil, action: nil)
    loginButton.tintColor = .label
    navigationItem.rightBarButtonItem = loginButton
}

你知道怎么解决吗? 请帮助我。

https://developer.apple.com/documentation/uikit/uiviewcontroller/1621515-edgesforextendedlayout

我已将 ViewController 中“延伸边缘”选项的“下顶栏”设置为“假”。

https://i.imgur.com/eVudSQO.png

这样解决了!