UITableView content overlaps Status Bar when UISearchBar is active

后端 未结 8 620
北海茫月
北海茫月 2021-02-05 02:17

I have a UITableViewController with a UISearchBar and UISearchDisplayController. That exists inside a Container View in a UIViewController which is in a UINavigationController.

8条回答
  •  一生所求
    2021-02-05 02:50

    Here's what worked for me:

    DO:

    • Use UISearchController (not a separately placed UISearchBar)
    • Place your VC in a UINavigationController if it isn't already. Set the nav not to "Show Navigation Bar" if desired.
    • Use autolayout for the UITableView (not springs and struts) and pin the top of the table to the top of the VC's view.
    • Add this delegate method:

    - (UIBarPosition)positionForBar:(id)bar { return UIBarPositionTopAttached; }

    DON'T:

    • Fiddle with edgesForExtendedLayout
    • Fiddle with extendedLayoutIncludesOpaqueBars
    • Fiddle with the table's contentInset

提交回复
热议问题