我一直在将我的搜索从旧的UISearchDisplayController转换为新的UISearchController。我现在已经完成了所有工作,但我的最后一个问题是显示的结果tableview。 结果表视图显示在搜索栏下方,当您向下滚动表视图时,会通过状态栏。
附上一些显示问题的图片,是否有任何人对于为什么会这样做有任何建议。我已经从ViewDidLoad中包含了一些设置代码。
Search Tableview before searching
Search Tableview after searching & scrolling
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars=NO;
self.automaticallyAdjustsScrollViewInsets=NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
[super viewDidLoad];
self.extendedLayoutIncludesOpaqueBars = YES;
self.navigationController.navigationBar.translucent = NO;
[self setNeedsStatusBarAppearanceUpdate];
// create a filtered list that will contain products for the search results table.
self.filteredItems = [NSMutableArray arrayWithCapacity:[self.listContent count]];
// Initially display the full list. This variable will toggle between the full and the filtered lists.
self.displayedItems = self.listContent;
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
[self.searchController.searchBar sizeToFit];
self.searchController.searchBar.placeholder = @"";
// Add the UISearchBar to the top header of the table view
self.TV.tableHeaderView = self.searchController.searchBar;
self.definesPresentationContext = YES;
UIView *theView = [[UIView alloc] initWithFrame:TV.frame];
[theView setBackgroundColor:[UIColor colorWithRed:0.090 green:0.388 blue:0.643 alpha:1]];
[TV setBackgroundView:theView];
[TV reloadData];
self.navigationItem.title = @"Search";
`
谢谢, 安德鲁