The display of the tab bar becomes blank when you switch back with the active search bar.

Update 2:

Since people are still looking at this question: know that I realized that it is impossible to reproduce this error on a real isolated iOS device. When you present the search controller, iOS also introduces a keyboard that spans the tab bar. To switch tabs, you must remove the keyboard, which will also reject the search controller.

The reason I say "isolated" is because I don’t know if you can play it using the Bluetooth keyboard and not try it. IOS keyboard cannot be presented with an external keyboard connected


Update:

I added viewWillDisappear to override View 1 and found interesting results:

If there is no search bar, switching tabs cancels the view before loading the next view. However, when the search bar is present, the view is NOT discarded before loading the next view.


I have a tab bar controller in the root that has 2 tabs. Each of them goes to the navigation controller, which puts the device into view mode. Here's a rough diagram:

/-> Navigation Controller -> View 1 tab bar controller \-> Navigation Controller -> View 2 

This is working fine. However, View 1 has a UISearchController. The error is that if you click the search button, a search controller will be presented. If you then click View 2 on the tab bar and return to View 1, the search controller still exists and the view is black.

My current hacking β€œfix” is to disable the tab bar when the search bar is obvious and turn it back on if the user selects β€œCancel”. This has 2 problems:

  • He twitches; the user should be able to switch tabs whenever he wants
  • It only reactivates if the user clicks Cancel, and not if they just exit the search

How can i fix this? Here are photos of what I'm talking about

enter image description here

enter image description here

enter image description here

enter image description here

+5
source share
1 answer

I solved this by running the answer to: UISearchController calls up Swift 2.0 black screen

I implemented it like this: viewDidLoad :

  self.definesPresentationContext = true searchController.searchResultsUpdater = self searchController.searchBar.delegate = self searchController.dimsBackgroundDuringPresentation = false searchController.definesPresentationContext = true 

This pretty much solved the problem for me. Then I ran into another problem, trying to step back into didSelectRowAt , which had never been an issue before. I solved this by first clicking on the UISearchController and then doing segue as usual:

_ = self.navigationController?.popViewController(animated: true)

+6
source

All Articles