2
所以我有一個UIPopOverController
裏面的tableview,我附加了一個UISearchBar到tableview的頭部,我有UISearchDisplayController
顯示正確的結果。但是,我無法在UIPopoverController
窗口中顯示結果。它顯示在彈出視圖後面,覆蓋屏幕一半的DetailView
(iPad的SplitViewController
)。如何將結果/表格視圖帶入彈出視圖?我嘗試將searchTableView
添加到popover視圖,但它只是掩蓋了原始的tableview。UISearchDisplayController裏面的UIPopOverController - searchResultsTableView不能正常顯示
這裏是設置此功能的代碼:
//Initialize Popover Controller
UIView *ccPopoverView = [[UIView alloc] init];
UIViewController* popoverTableContent = [[UIViewController alloc] init];
self.ccTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 44, 320, 400) style:UITableViewStylePlain];
self.ccTableView.dataSource = self;
self.ccTableView.delegate = self;
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320.0, 44.0)];
self.searchDisplayController = [[UISearchDisplayController alloc]initWithSearchBar:self.searchBar contentsController:self];
self.searchDisplayController.searchResultsDataSource = self;
self.searchDisplayController.searchResultsDelegate = self;
self.searchDisplayController.delegate = self;
searchBar.frame = CGRectMake(0, 0, 0, 38);
self.ccTableView.tableHeaderView = searchBar;
ccPopoverView.backgroundColor = [UIColor blackColor];
//Here is where I tried adding the searchResultsTableView as a subview.
//[ccPopoverView addSubview:self.searchDisplayController.searchResultsTableView];
[ccPopoverView addSubview:self.ccTableView];
popoverTableContent.view = ccPopoverView;
self.popoverTableController.delegate = self;
self.popoverTableController = [[UIPopoverController alloc] initWithContentViewController:popoverTableContent];
[self.popoverTableController setPopoverContentSize:CGSizeMake(320, 440) animated:NO];
謝謝!