Search code examples
iosswiftanimationuisearchcontroller

Force End Editing on a UISearchController without animation


I would like to remove the searchBar form the UI when I pop my current ViewController. Now I do this:

 override func viewWillDisappear(animated: Bool) {
  resultSearchController.active = false //Need improvement here. remove animation
  super.viewWillDisappear(animated)
}

What's happening here is that the UISearchController is dismissed but with animation... And It looks very bad in the current state. I would like it to go back to its initial state without animation before the viewController disappear with its own animation.


Solution

  • Allllright

    here is the solution:

    resultSearchController.dismissViewControllerAnimated(false) { () -> Void in
      //completion block
    }
    

    false being the "flag" value for saying: I don't want any animation.