[英]Resetting the search query string in UISearchController programmatically
我無法以編程方式重置/替換搜索查詢字符串。 我試圖從UISearchControllerDelegate內修改UISearchBar查詢字符串。
我正在使用聽寫輸入。
說出命令“ delete”時,應該將searchController.searchBar.text
設置回@""
。 語音檢測應與空字符串一樣正常進行。
查詢字符串確實重置為@""
,但是語音檢測停止。
如何以編程方式在UISearchController中重置搜索查詢字符串,並且仍然能夠繼續使用語音輸入?
- (void)updateSearchResultsForSearchController:(nonnull UISearchController *)searchController {
NSString *searchQuery = self.searchController.searchBar.text;
// Deletion command
if ([self.searchController.searchBar.text hasSuffix:@"delete"]) {
// Things that I've tried that don't work
//[self.searchController.searchBar setText:@""];
//self.searchController = [self.searchController init];
//self.searchController.searchBar.text = @"";
searchQuery = @"";
}
}
此功能在iOS中尚不可用。 嘗試清除searchBar的TextField中的文本后,它將鍵盤模式更改為小鍵盤輸入。
因此,結論是,您只能使用聽寫命令將輸入提供給textField,而不能清除它。 用戶必須手動執行該過程才能再次更改為“聽寫輸入”。
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.