While i was updating my project to iOS 13 i faced with unusual issue.
I have logic for showing and handling some UISearchController
actions (code below), all parts were working perfectly in iOS 11 & 12.
My task was to add search button at navigation bar to show UISearchController
after button action.
But in iOS 13, i got 2 issues:
Code that invokes from button action
func showSearch() {
let searchResultsController = LUSearchResultsViewController()...
let searchController = UISearchController(searchResultsController: searchResultsController)
searchController.delegate = self
searchController.searchResultsUpdater = searchResultsController
navigationItem.searchController = searchController
definesPresentationContext = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
searchController.isActive = true
}
}
Only one solution helps me to show search controller without any diffs from previous iOS versions.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
searchController.isActive = true
}
Code that works on iOS 13, on iOS 11 and 12 code works without asyncAfter
Code that helps me to hide UISearchController
and set navigation bar initial state in iOS 11 and 12, and not in 13. After tapping cancel on SearchBar, UISearchController
begins to call delegate methods.
//MARK: UISearchControllerDelegate
public func willDismissSearchController(_ searchController: UISearchController) {
self.navigationItem.searchController = nil
}
BUT
After setting navigationItem.searchController = nil
didPresentSearchController
calls twice and not only UISearchController
dismissed, but whole UIViewController
hierarchy right to UIWindow
. Or if i add asyncAfter
here i get normal dismiss with expanded nav bar height, that i don't need.
SO
Impressive battery life, a svelte design, a tactile keyboard, and zippy performance scores are the most important features I look for while reviewing laptops, and the Swift 5 met — and even surpassed — my expectations. The refreshed Acer Swift 5 comes with a new 12th Gen Intel Core i7 CPU that outperforms its rivals.
Get hands-on with the WQXGA1 touch display with Antimicrobial Corning® Gorilla® Glass,4 boasting an impressive screen-to-body ratio for thin bezels all around.
Acer Swift 5 (2022): Performance Its benchmark scores are better than other laptops with similar specs, so it's more than capable of handling low and modestly demanding games.
The premium, aerospace-grade aluminum chassis is CNC-machined to an incredible 14.95 mm and 1.2 kg. The masterfully crafted design extends to the eco-friendly OceanGlass™ touchpad and a power button featuring a fingerprint reader.
This issue is happening on iOS 13
Add searchController.extendedLayoutIncludesOpaqueBars = true
as well as
`
extension SearchViewController:UISearchControllerDelegate{
func willPresentSearchController(_ searchController: UISearchController) {
if #available(iOS 13, *){
self.navigationController?.navigationBar.isTranslucent = true
}
}
func willDismissSearchController(_ searchController: UISearchController) {
if #available(iOS 13, *){
self.navigationController?.navigationBar.isTranslucent = false
}
}
}
`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With