We have a class SearchTableViewController
that holds a UISearchBar
as the tableViewHeader
of its UITableView
.
We also use a UISearchDisplayController
whose delegate (searchResultsDelegate
and searchResultsDataSource
) is the same controller that holds the tableView containing the searchBar.
Searching itself works just fine, but the animation when entering/exiting search mode is really weird:
Weird animation 1
In another view controller (a subclass of the SearchTableViewController
), the issue is even more noticeable:
Weird animation 2
I have tried implementing the various UISearchDisplayDelegate
methods (such as -(void)searchDisplayControllerWillBeginSearch:
), but they are either being called too late (when the animation is already finished) or only when giving the UISearchBar
s textfield the focus.
Are there any methods I am missing that might allow me to change the animation before it happens?
Also, notice how the navigation bar immediately disappears in the first video. I have tried manually setting it to 'not hidden' in multiple spots, which didn't change anything.
Our navigationBar
is configured to not be translucent, if that makes any difference.
On iOS 6, everything works as expected, the searchBar smoothly pushes the navigationBar upwards.
Will post code if necessary, but we are not modifying the standard behaviour in any way (setting frames, overwriting delegate methods etc.).
Any ideas what might be the cause for the strange animations?
I talked with an Apple engineer at the iOS 7 Tech Talks, who also couldn't help me. After further investigation, I found the first problem to be the default behaviour for iOS 7(.0.4).
Update: The bug is still present in 7.1.
Second Update: The bug is still present in 8.1.
Third Update: The bug is still present in 8.4.
Fourth Update: The bug is still present in 9.2
Steps to reproduce:
About the second strange animation: The problem was that the first view controller was created from a nib while the second one was created programmatically. Therefore, the following calls were missing:
[self setAutomaticallyAdjustsScrollViewInsets:YES];
[self setExtendedLayoutIncludesOpaqueBars:YES];
After including these two lines in viewDidLoad:
, the animation looks 'fine' - that is, same as buggy as the one from the sample project.
My answer here helped my specific situation for strange animation behavior:
I found that
self.navigationController.navigationBar.translucent = YES;
made my animation less buggy
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