UISearchController search bar overlap first cell when active

前端 未结 7 2441
慢半拍i
慢半拍i 2020-12-21 08:52

I am using UISearchController to search for data in my tableview. I am not using table view controller. I would like to hide the navigation bar when my search b

相关标签:
7条回答
  • 2020-12-21 09:58

    You can add content inset from the top instead of adding a header.

      self.tableView.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0)
    

    and when willDismissSearchController (UISearchController's delegate method) is called, return the insets to 0

      self.tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    

    This way, you'll avoid the whitespace when it's not active.

    0 讨论(0)
提交回复
热议问题