gpt4 book ai didi

objective-c - 隐藏搜索显示 Controller 的 TableView

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:22 27 4
gpt4 key购买 nike

我想让搜索显示 Controller 以这种方式工作:

当用户按下搜索字段时,它会上升到顶部并显示键盘。通常情况下会发生这种情况,但当用户键入内容时会显示表格 View 。

我不想在用户输入时做任何事情,当他按下 Search 时,我会这样做:

 [_searchController setActive:NO animated:YES];

并在我的自定义创建 TableView 中加载数据。

我怎样才能实现这种功能。

编辑。我找到了一些解决方案:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
savedSearchTerm = searchString;

[controller.searchResultsTableView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.8]];
[controller.searchResultsTableView setRowHeight:800];
[controller.searchResultsTableView setScrollEnabled:NO];
return NO;
}

也许有人有更好的方法?

最佳答案

您可以设置searchResultsTableViewhidden 属性

controller.searchResultsTableView.hidden = YES;

每当你想要它回来时,只需将 hidden 设置为 NO 并将它带到前面,以防它已经显示

controller.searchResultsTableView.hidden = NO;
[controller.searchResultsTableView.superview bringSubviewToFront:controller.searchResultsTableView];

关于objective-c - 隐藏搜索显示 Controller 的 TableView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12005903/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com