I am trying to dismiss the keyboard when a uisearchdisplaycontroller is no longer active on the iPhone 6 plus. I can end editing of the search bar but the keyboard stays active on the screen. I have tried many ways, but here is my current code.
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
if(searchDisplayController!.active) {
self.view.endEditing(true)
self.searchDisplayController!.active = false
}
}
Any ideas?
Try using below function for detecting rotation:
Also use resignFirstResponder for hiding the keyboard.