Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation bar gets blocked after pressing Cancel in UISearchController

I`m preparing app for iOS 13, and get bug with search controller in navigation bar. How to solve navigation bar glitch?

let search = UISearchController(searchResultsController: nil)

search.dimsBackgroundDuringPresentation = false
search.searchResultsUpdater = self
search.hidesNavigationBarDuringPresentation = false
self.definesPresentationContext = true
search.searchBar.isTranslucent = false

self.navigationItem.searchController = search

self.navigationItem.hidesSearchBarWhenScrolling = true

enter image description here

Press Cancel and navigation bar items becomes untouchable. Pushing view controller leads to navigation bar item overlap.

enter image description here

I have created test project on git https://github.com/eKroman/TESTsearchBar

Bug appears on iOS 13 beta (tested on iPad) using from Xcode 11 from beta 7 (maybe older beta) to Xcode 11 GM seed 2. Does not appear on simulators.

like image 326
Edgar Kroman Avatar asked Sep 16 '19 12:09

Edgar Kroman


Video Answer


1 Answers

I encountered the same problem, if I cancel the searchBar and change the navigationItem.title then I have a double title 👍. It's like a ghost layer of the navigation bar stays here in the navigation controller.

This is how I fixed it:

searchController.hidesNavigationBarDuringPresentation = true

Probably best to use it until Apple fix this issue.

I also noticed that the back button switch to default color (blue), as if the navigationBar TintColor was reset.

Config: - Xcode 11.0 (11A420a) - iOS 13.1 (17A5844a)

like image 73
CoachThys Avatar answered Sep 16 '22 11:09

CoachThys