Swift: Back button should be pressed twice while SearchBar is active

时间:2018-01-23 19:44:33

标签: swift uinavigationcontroller uinavigationbar uisearchbar uisearchcontroller

I have a UITableViewController embedded in a navigation bar and standard Search bar implementation. I don't hide the navigation bar while the search bar is active. The problem is that while the search bar is active, every button in the navigation bar, like a "Back" button, should be pressed twice— the first time to make the search bar inactive. How can I avoid that? Thank you.

1 个答案:

答案 0 :(得分:0)

在viewDidLoad

上添加此代码
    self.definesPresentationContext = true

如果您的navigationBar是Opaque

,请添加此项
    self.extendedLayoutIncludesOpaqueBars = true