iOS中UITableView的UISearchDisplayController框架

nic*_*ljs 4 iphone uisearchbar uisearchdisplaycontroller ios

  • 我有UITable一个UISearchDisplayController.
  • UITable是小于屏幕的宽度(它是280像素宽度居中).
  • 当我点击时search bar,UISearchDisplayController表格一直到屏幕的左边.
  • 即使改变桌子的框架UISearchDisplayController,我仍然得到相同的定位.

我在这里设置框架:

- (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);
}
Run Code Online (Sandbox Code Playgroud)

甚至更奇怪的是,当我在最后记录搜索表位置时,它显示16.但是,它在视图中的位置0处.

任何帮助表示赞赏.

nic*_*ljs 20

我回答了自己的问题.需要在此委托方法中设置框架:

- (void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView  {

    tableView.frame = self.myTable.frame;

}
Run Code Online (Sandbox Code Playgroud)