[英]how to activate a UISearchDisplayController with pre-set term?
我正在以一种非常规的方式使用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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.