iOS UISearchController 宽度不等于屏幕,右边小于屏幕
iOS UISearchController width Not equal screen,Right less than screen
- (UISearchController *)searchController {
if (_searchController == nil) {
_searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
_searchController.searchResultsUpdater = self;
_searchController.hidesNavigationBarDuringPresentation = YES;
_searchController.dimsBackgroundDuringPresentation = YES;
self.tableView.tableHeaderView = _searchController.searchBar;
}
return _searchController;
}
不要使用 UITableViewController,而是使用 UIViewController 子类。安排 Searchbar 和 Tableview。不要将搜索栏放在表视图中 header。
注意:带有索引搜索的 UITableViewController 始终会在右侧为您提供额外的 space。
- (UISearchController *)searchController {
if (_searchController == nil) {
_searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
_searchController.searchResultsUpdater = self;
_searchController.hidesNavigationBarDuringPresentation = YES;
_searchController.dimsBackgroundDuringPresentation = YES;
self.tableView.tableHeaderView = _searchController.searchBar;
}
return _searchController;
}
不要使用 UITableViewController,而是使用 UIViewController 子类。安排 Searchbar 和 Tableview。不要将搜索栏放在表视图中 header。
注意:带有索引搜索的 UITableViewController 始终会在右侧为您提供额外的 space。