Xcode 10.1, Swift 4.2
ViewController A has LargeTitles, UISearchController and UITableView in operation.
When pushing ViewController B (also a TableView) after selecting a TableViewCell, there is a delay in the space that was occupied by the UISearchBar being removed as shown in the animation.
ViewController B also has a UISearchController, but as per usual behaviour, is hidden until the user drags down on the screen.
Does anyone know how to prevent this from happening?
Additional Information & Code:
ViewController A When cell tapped, it pushes ViewController B using a Show (e.g Push) segue on Storyboard with Animates selected. Data is injected using the prepareForSegue method.
performSegue(withIdentifier: "showLogbook", sender: self)
ViewController B:
class LogbookVC: UIViewController, UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UISearchResultsUpdating {
//Extract
private let searchController = UISearchController(searchResultsController: nil)
@IBOutlet private var addButton: UIBarButtonItem!
@IBOutlet private var shareButton: UIBarButtonItem!
@IBOutlet private var backButton: UIBarButtonItem!
@IBOutlet private var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.rowHeight = 75.0
//loading tableView data
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.prefersLargeTitles = true
self.definesPresentationContext = true
configureSearchController()
fetchAndSortLogEntries()
}
private func configureSearchController() {
navigationItem.searchController = searchController
searchController.searchResultsUpdater = self
searchController.searchBar.scopeButtonTitles = ["Newest", "Oldest"]
searchController.searchBar.delegate = self
searchController.searchBar.barStyle = .black
searchController.searchBar.tintColor = K.Colors.appMid
searchController.searchBar.keyboardAppearance = .dark
searchController.searchBar.returnKeyType = .done
searchController.dimsBackgroundDuringPresentation = false
let attributes = [NSAttributedString.Key.foregroundColor: K.Colors.appMid]
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).setTitleTextAttributes(attributes, for: .normal)
searchController.searchBar.setValue("Reset", forKey: "_cancelButtonText")
let searchBarCancelButton = searchController.searchBar.value(forKey: "cancelButton") as? UIButton
searchBarCancelButton?.setTitle("Reset", for: .normal)
}
viewDidAppear
for example? – devios1