Search code examples
iosswiftsearchbar

hide custom search bar on start


in my swift 2 app i have a table view controller where i added a custom search bar (dark grey row)

in the viewDidLoad i call

configureCustomSearchController()

this is the function:

  func configureCustomSearchController() {
       customSearchController = CustomSearchController(
          searchResultsController: self,
          searchBarFrame: CGRectMake(0.0, 0.0, MyTable.frame.size.width, 50.0),
          MyTable.tableHeaderView = customSearchController.customSearchBar
          customSearchController.searchBar.sizeToFit()
          customSearchController.customDelegate = self
        }



    func updateSearchResultsForSearchController(searchController: UISearchController) {
        // DO SOMETHING
    }

    func didStartSearching() {
        // DO SOMETHING
    }


    func didTapOnSearchButton() {
        // DO SOMETHING
    }


    func didTapOnCancelButton() {
        // DO SOMETHING
    }

    func didChangeSearchText(searchText: String) {
        // DO SOMETHING
    }

enter image description here

My Question is, how can i hide the searcher, if my tableview will appear and show the sidebar if i pull down.

a pull down refresh function is available.


Solution

  • i found my solution:

    viewDidLoad

    MYTable.contentInset = UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0)
    

    this hide the searchbar on start and if i scroll a little bit up, the search Bar will be visible