iOS 7 searchdisplaycontroller and tableview offset disagreeing offsets

Viewed 328

I have a tableview in a RectEdgeAll view controller and a search bar as its tableview header. When I start searching, the search bar animates and settles into the normal position at top of the screen but the tableview doesn't follow it, it remains in the same position before starting the search leaving a gap between both views. How do I make it animate along with the search bar?

I tried already updating the contentOffset of the tableview when search start but it didn't even moved.

Tried both ways the tableview and search bar: code and storyboard.

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.tableView.dataSource = self;
    self.tableView.delegate = self;

    //self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    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 Search:

enter image description here

After Search:

enter image description here

1 Answers
Related