Reputation: 27428
I've embed UISearchController into the navigationbar and my view controller has the table view. When I click on searchbar and keyboard appears tableview and searchbar does not animate smoothly. It seems like searchbar is overlaping navigationbar.
Here is the code,
Declare searchcontroller as a variable like,
var resultSearchController = UISearchController()
and defination in viewDidLoad is like,
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.obscuresBackgroundDuringPresentation = false;
self.navigationItem.searchController = controller
return controller
})()
Animation issue is like below gif(watch till end to see slow animation)
I want same duration for animation for tableview, navigation bar, and searchbar.
Any help will be appreciated.
Upvotes: 0
Views: 644
Reputation: 51
In my case disabling Use Safe Area Layout Guides
for UIViewController
checkbox in storyboard fixed the issue 💀.
After disabling it make sure:
Top Layout Guide
's bottom - must be constrainted to the most top subview from your viewController.Bottom Layout Guide
' top - must be constrainted to the most bottom subview from viewController.P.S.
This is also fixes problem with scopeBar
animation issue.
I figured this out by using this article's materials. MasterViewController is Main.storyboard. If you are confused you can check it out yourself.
https://www.kodeco.com/4363809-uisearchcontroller-tutorial-getting-started
Upvotes: 0
Reputation: 1163
Important extra note to the accepted answer:
If you use a UIViewController
with subviews, including a UITableView
, the UITableView
has to be the first subview (i.e.: at index 0).
Upvotes: 0
Reputation: 1044
Don't set UITableView
top anchor to be pinned to safeArea
but to superview
.
Upvotes: 2