aと aをUIViewController
含むクラスがあります。私が直面している問題は、検索バーをクリックしてクエリを入力するたびに..検索結果の両方が表示され、何らかの理由で基になる UITableView が表示されることです。UITableView
SearchDisplayController
たとえば、検索の実行中にこのコードを実行すると、次のようになります。
- (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 は次のようになります。
と
明確にするために..表示されたUIはまさに私が望むものです..しかし、なぜ他のテーブルがこれらすべてのレンダリング計算を行っているのかについて混乱しています..これは後で本当の問題になりますb / cそれは私にいくらかのスレッドを与えています/asynchronous コードの頭痛の種であり、このバックグラウンドと不要なアクティビティが発生している間はデバッグが非常に困難です。
注: IB でさまざまなレイアウトも試してみました.1 つ気付いたのは、検索バーを tableView に隣接するサブビューにすると、基になるテーブルがさらに呼び出されることです!
また、フラグを作成して検索バーが現在使用されているかどうかを確認し、基本的に基になる UITableView が作業を行わないようにすることも考えました..しかし、それは十分ではありません..そもそも呼び出されるべきではありません.
検索を使用しているときに、基になるテーブルがまったく表示/レンダリングされないようにする方法を誰かに教えてもらえますか?