hide search bar when show search

This commit is contained in:
Chris Li 2017-01-04 23:37:59 -05:00
parent fdeb7bf39d
commit fcf6fc46a4

View File

@ -81,6 +81,8 @@ extension MainController: SearchBarDelegate, SearchContainerDelegate {
controller.delegate = self
guard !childViewControllers.contains(controller) else {return}
navigationController?.setToolbarHidden(true, animated: animated)
// add cancel button if needed
if traitCollection.horizontalSizeClass == .compact {
navigationItem.setRightBarButton(buttons.cancel, animated: animated)
@ -111,6 +113,8 @@ extension MainController: SearchBarDelegate, SearchContainerDelegate {
private func hideSearch(animated: Bool) {
guard let searchController = childViewControllers.flatMap({$0 as? SearchContainer}).first else {return}
navigationController?.setToolbarHidden(false, animated: animated)
// remove cancel button if needed
if traitCollection.horizontalSizeClass == .compact {
navigationItem.setRightBarButton(nil, animated: animated)