0

uisearch バーと uisearchbardisplaycontoller をプログラムで追加し (NO XIB)、検索バーはテーブル ヘッダーに表示されますが、機能しません。

setActive:YES、setActive:NO ディスプレイ コントローラの場合、正常に表示され、機能します。

なぜこれが起こっているのでしょうか?

前もって感謝します

searchBar = [[UISearchBar alloc] init];
[self setSearchBarDisplayController:[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]];
[[self searchBarDisplayController] setDelegate:self];
[[self searchBarDisplayController] setSearchResultsDataSource:self];

summaryTableView = [[[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 416.0) style:UITableViewStylePlain] autorelease]; 
[summaryTableView setDataSource:self];
[summaryTableView setDelegate:self];
[summaryTableView setBackgroundColor:[UIColor clearColor]];
[summaryTableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
[summaryTableView setRowHeight:[PayCell height]];

[summaryTableView setTableHeaderView:searchBar];

[self.view addSubview:summaryTableView];

[searchBarDisplayController setActive:YES];
[searchBarDisplayController setActive:NO];
4

1 に答える 1

0

検索表示コントローラーの searchResultsDelegate を設定していない可能性がありますか?

    self.searchDisplayController.searchResultsDelegate = self;

開発者サイトでは、これが参照されています。もっとコードを見ないで、それを言うのは難しいですが、それを設定しないことが問題の根本になる可能性があります. ここに抜粋があります:

searchResultsDelegate 検索結果が表示されるテーブル ビューのデリゲート。

@property(nonatomic, assign) id searchResultsDelegate ディスカッション デフォルトは nil です。

于 2011-04-24T14:57:35.150 に答える