Search code examples
objective-cios7ios8uisearchbaruisearchdisplaycontroller

UISearchBar animation issue using UISearchDisplayController


I have a UITableViewController whose table view is displaying a list of calendar entries. The controller is created programatically and is embedded in a UINavigationController.

In the view controller's viewDidLoad method I'm calling another method to instantiate a UISearchBar and a UISearchDisplayController.

Here's the code that does that:

- (void)configureSearch {
UISearchBar *searchBar = [UISearchBar new];
self.sdc = [[UISearchDisplayController alloc] initWithSearchBar:searchBar
                                             contentsController:self];

self.sdc.delegate = self;
self.tableView.tableHeaderView = searchBar;
}

Doing so, I'm seeing a strange animation issue where the search bar "snaps" into place when it becomes and resigns first responder status.

Attached video shows this behaviour and normals speed and with slow animations enabled.

Link to the screen recording is here.

Any suggestions would be appreciated.


Solution

  • Calling -[UISearchDisplayController setActive:NO animated:NO] from within a UIView animation block has solved the issue for me.