iPhone隐藏UISearchDisplayController结果?
我目前有一个 UISearchBar 和 UISearchDisplayController 实现为:
- (void) viewDidLoad {
videoList = [[NSMutableArray alloc]init];
//Add the search bar
aSearchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
[aSearchBar sizeToFit];
aSearchBar.delegate = self;
aSearchBar.placeholder = @"Search YouTube...";
self.tableView.tableHeaderView = aSearchBar;
searchDC = [[UISearchDisplayController alloc] initWithSearchBar:aSearchBar contentsController:self];
[self performSelector:@selector(setSearchDisplayController:) withObject:searchDC];
searchDC.delegate = self;
searchDC.searchResultsDataSource = self.tableView.dataSource;
searchDC.searchResultsDelegate = self.tableView.delegate;
[aSearchBar release];
[searchDC release];
}
当用户键入内容并点击搜索时,一个 tableView 会出现在后台的 tableView 顶部。
是否有隐藏此“searchResults tableView”的方法? (我只希望后台表保存数据......它目前所做的)。
即有财产吗?例如 searchDisplayController.tableView.visible=NO 或类似的?
I currently have a UISearchBar and UISearchDisplayController implemented as:
- (void) viewDidLoad {
videoList = [[NSMutableArray alloc]init];
//Add the search bar
aSearchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
[aSearchBar sizeToFit];
aSearchBar.delegate = self;
aSearchBar.placeholder = @"Search YouTube...";
self.tableView.tableHeaderView = aSearchBar;
searchDC = [[UISearchDisplayController alloc] initWithSearchBar:aSearchBar contentsController:self];
[self performSelector:@selector(setSearchDisplayController:) withObject:searchDC];
searchDC.delegate = self;
searchDC.searchResultsDataSource = self.tableView.dataSource;
searchDC.searchResultsDelegate = self.tableView.delegate;
[aSearchBar release];
[searchDC release];
}
When the user types something and hits search, a tableView appears on top of the tableView in the background.
Is there anyway of hiding this 'searchResults tableView' ? (I just want the background table to hold the data..which it currently does).
i.e. is there a property? e.g. searchDisplayController.tableView.visible=NO or similar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
然而,这并不会关闭搜索界面(搜索栏和“取消”按钮)。下一个代码可以做到这一点:
This however doesn't dismiss the search interface (search bar and "cancel" button). The next code does it:
[[UISearchBar 分配] initWithFrame:CGRectZero];
不要使用 CGRectZero
self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.table.frame.size.width, 44)];
尝试一下
[[UISearchBar alloc] initWithFrame:CGRectZero];
don't use CGRectZero
self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.table.frame.size.width, 44)];
try it