0

以编程方式添加了 uisearch bar 和 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 Discussion 默认为 nil。

于 2011-04-24T14:57:35.150 回答