- I have a
UITablethat has aUISearchDisplayController. - The
UITableis less than the width of the screen (it’s 280px width centered). - When I tap on the
search bar, theUISearchDisplayControllertable is all the way to the left of the screen. - Even when changing the frame of the table of the
UISearchDisplayController, I still get the same positioning.
I set the frame here:
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView {
tableView.backgroundColor = [UIColor colorWithRed:29.0/255.0 green:30.0/255.0 blue:32.0/255.0 alpha:1];
tableView.rowHeight = self.myTable.rowHeight;
tableView.frame = myTable.frame;
NSLog(@"search table origin: %f",tableView.frame.origin.x);
}
Even weirder, when I log the search table position at the end, it shows 16. However, it is at position 0 in the view.
Any help is appreciated.
I answered my own question. The frame needs to be set in this delegate method: