簡體   English   中英

如何激活具有預設術語的UISearchDisplayController?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM