I have a table view in the RectEdgeAll view controller and a search bar as a table title. When I start the search, the search bar animates and settles to a normal position at the top of the screen, but the table view does not follow it, it remains in the same position before starting the search, leaving a space between both views. How to create an animation with the search bar?
I tried to update the table's contentOffset already when the search started, but it was not even moved.
I tried the table and the search bar in both directions: code and storyboard.
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.searchBar.delegate = self;
self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
self.searchController.delegate = self;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.view addSubview:self.tableView];
self.tableView.tableHeaderView = self.searchBar;
}
Before searching:

After the search:
