【发布时间】:2017-12-28 12:39:19
【问题描述】:
iOS 11 我在表格的标题视图上有一个UITableViewController 和一个UISearchController,使用以下代码:
if(searchController == nil)
{
searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
searchController.dimsBackgroundDuringPresentation = false;
searchController.searchResultsUpdater = self;
searchController.searchBar.delegate = self;
self.definesPresentationContext = NO;
searchController.delegate = self;
}
self.tableView.tableHeaderView = searchController.searchBar;
[self.tableView setContentOffset:CGPointMake(0,searchController.searchBar.bounds.size.height) animated:YES];
当我运行应用程序时,我想要的行为完全适用于行数超过设备屏幕高度的 tableview,但在 tableview 只有几行的情况下,搜索栏正在从导航栏下降一点。
When there are few cells on the tableview, the search bar drops down as in this picture
When there are more cells on the tableview, the search bar doesn't drop down
【问题讨论】:
标签: ios objective-c uitableview ios11 uisearchcontroller