gpt4 book ai didi

ios - 如何激活具有预设期限的 UISearchDisplayController?

转载 作者:可可西里 更新时间:2023-11-01 04:19:19 24 4
gpt4 key购买 nike

我正在以一种稍微非常规的方式使用 UISearchViewController。

我的 UISearchBar 最初是隐藏的。当用户点击按钮时,我取消隐藏 UISearchBar 并激活 UISearchViewController。我还设置了搜索栏的文本,并告诉搜索栏成为第一响应者。

问题是 UISearchDisplayController 创建的灰色叠加层仍然可见。它不会消失,除非我预设的文本被清除,并且用户开始重新输入。

    self.searchDisplayController.searchBar.hidden = NO;
self.searchDisplayController.searchBar.text = @"term";
[self.searchDisplayController.searchBar becomeFirstResponder]; // this actually appears to activate everything
[self.searchDisplayController setActive: YES animated: YES]; // this activates but does not set the searchbar to 1st responder...

为什么 UISearchDisplayController 继续显示它的灰色覆盖层,我该如何清除它?

最佳答案

更改调用顺序似乎可以解决问题。不知道为什么。

[self.searchDisplayController setActive: YES animated: YES]; 
self.searchDisplayController.searchBar.hidden = NO;
self.searchDisplayController.searchBar.text = @"term";
[self.searchDisplayController.searchBar becomeFirstResponder];

关于ios - 如何激活具有预设期限的 UISearchDisplayController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9608051/

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