我有一个UIViewController,它有分段控制和UITableView。 所有使用Autolayout,在故事板中设置。这里的约束代码软件i设置有:强制UISearchController显示搜索结果表全屏
H:|-[SegmentedControls]-|
H:|[TableView]|
V:|-[SegmentedControls]-[TableView]|
我已经加入UISearchController和作为的UISearchBar的表头视图。 为了显示搜索结果,我创建了一个新的UITableViewController。
UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
searchResultsController.tableView.dataSource = self;
searchResultsController.tableView.delegate = self;
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
self.searchController.delegate = self;
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);
self.clientListTable.tableHeaderView = self.searchController.searchBar;
self.searchController.searchBar.scopeButtonTitles = @[@"Active", @"Inactive"];
self.definesPresentationContext = YES;
但后来我遇到了以下问题 - 当我按下搜索栏上,它的动画,但所提出的观点需要,而不是只在屏幕的一部分,呈现在顶部和底部的暗淡的铬,呈现全屏。 呈现的视图的大小似乎等于其中一个托管搜索栏的tableview,它只是垂直居中在屏幕上。 我对如何重写搜索结果的呈现毫无头绪,以使它们全屏显示。我试图明确地设置ModalPresentationStyle两个呈现视图控制器和一个正在呈现,但它没有奏效。 我感到我需要以某种方式覆盖搜索结果的表示控制器,但我不知道从哪里开始,有什么想法?
你看过Apple的UICatalog示例代码吗? https://developer.apple.com/library/ios/samplecode/UICatalog/Introduction/Intro.html – 2015-08-29 01:45:49
这是我做的第一件事之一,下一个要求在苹果开发论坛和苹果开发支持 – 2015-08-29 13:40:13