Skip to content

Commit

Permalink
Fix searchbar hide issue (#6703)
Browse files Browse the repository at this point in the history
* remove hideSearchBarWhenScrolling in viewDidAppear

* unfold searchBar on viewDidAppear

Co-authored-by: Tomislav Eric <[email protected]>
  • Loading branch information
tomislaveric and Tomislav Eric authored Jun 16, 2020
1 parent 7916fe4 commit 4b4853b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,14 @@ class WebsiteDataManagementViewController: UIViewController, UITableViewDataSour
searchController.searchBar.barStyle = .black
}
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
self.searchController = searchController

definesPresentationContext = true
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

// Allows the search bar to be scrolled away even though we initially show it.
navigationItem.hidesSearchBarWhenScrolling = true
unfoldSearchbar()
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
Expand Down Expand Up @@ -247,4 +244,9 @@ class WebsiteDataManagementViewController: UIViewController, UITableViewDataSour
showMoreButtonEnabled = false
tableView.reloadData()
}

private func unfoldSearchbar() {
guard let searchBarHeight = navigationItem.searchController?.searchBar.intrinsicContentSize.height else { return }
tableView.setContentOffset(CGPoint(x: 0, y: -searchBarHeight + tableView.contentOffset.y), animated: true)
}
}

0 comments on commit 4b4853b

Please sign in to comment.