我有一個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