Tableview wont scroll to top. Obscured by UISearchBar filtered. On Return Segue

I have a UISearchBar at the top of a TableView with UISearchController.

The problem I am facing is that it works fine and allows me to scroll to the top of the TableView even after I have filtered the results.

The problem lies when the user clicks on a cell in the tableview, they are taken to another view controller. When they select back and the user is returned to the ViewController, they cant scroll to the top of the TableView. It is obscured under the SearchBar.

I have included the code of the ViewDidLoad

override func viewDidLoad() {     super.viewDidLoad()      configureView() } 

Below is the function I call configuring the SearchController.

func configureView() {  searchController.searchResultsUpdater = self searchController.obscuresBackgroundDuringPresentation = false searchController.hidesNavigationBarDuringPresentation = true searchController.searchBar.placeholder = "Search Term of Abbreviation" searchController.searchBar.set(textColor: .white) searchController.searchBar.setPlaceholder(textColor: .white) searchController.searchBar.setClearButton(color: .white) searchController.searchBar.setSearchImage(color: .white)  navigationItem.searchController = searchController definesPresentationContext = true  searchController.searchBar.scopeButtonTitles = { $0.rawValue } searchController.searchBar.delegate = self   let navBar = self.navigationController?.navigationBar  navBar?.barTintColor = .termsLogoBlue navBar?.tintColor = UIColor.white navBar?.isTranslucent = false navBar?.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white] } 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.