做底層UIViewTable顯示我有一個UIViewController
類,它包含一個UITableView
和SearchDisplayController
。我面臨的問題是,無論何時點擊搜索欄並輸入查詢,它都會顯示搜索結果,並出於某種原因顯示底層的UITableView。爲什麼每當我使用搜索顯示控制器
因此,例如,如果我運行此代碼,而我正在尋找:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == self.searchDisplayController.searchResultsTableView) {
..
NSLog(@"constructing a search result table view cell ");
} else
{
..
NSLog(@"::: constructing a mail box table view cell");
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.searchDisplayController.searchResultsTableView) {
NSLog(@"searchDisplayController: number of rows: %d", [queryResultData count]);
} else {
NSLog(@"mailbox: NUMBER OF ROWS: %d", [self.emailData count]);
}
}
日誌看起來是這樣:
[5033:c07] performing search with query hi
[5033:c07] ftSearch started with query = hi dbNum = 0
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] searchDisplayController: number of rows are 1
[5033:c07] ::: constructing a search result table view cell
[5033:c07] searchDisplayController: number of rows are 2
[5033:c07] ::: constructing a search result table view cell
[5033:c07] searchDisplayController: number of rows are 3
[5033:c07] ::: constructing a search result table view cell
[5033:c07] searchDisplayController: number of rows are 4
[5033:c07] ::: constructing a search result table view cell
[5033:c07] searchDisplayController: number of rows are 5
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] searchDisplayController: number of rows are 6
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] mailbox: NUMBER OF ROWS IN SECTION: 19
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
[5033:c07] ::: constructing a mail box table view cell
這是什麼IB樣子:
and
要清楚..所顯示的UI正是我所想要的..但我只是困惑,爲什麼其他表正在做所有這些渲染計算..這後來成爲了一個真正的問題b/c它給了我一些線程/異步代碼的頭痛,在這個背景和不必要的活動發生的時候真的很難調試。
note:我也嘗試了與IB的不同佈局..我注意到的一件事是,如果我讓搜索欄與tableView相鄰的子視圖,底層表將被調用更多!
我也想過創建一個標誌,並檢查如果搜索欄目前正在使用,然後基本上阻止底層UITAbleView做任何工作..但是這不夠好......它不應該被稱爲首先。
有人能告訴我如何防止底層表出現/正在使用搜索時呈現的所有內容?