Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 以编程方式重置UISearchController中的搜索查询字符串_Objective C_Uisearchbar_Uisearchcontroller_Uisearchbardelegate_Uisearchresultscontroller - Fatal编程技术网

Objective c 以编程方式重置UISearchController中的搜索查询字符串

Objective c 以编程方式重置UISearchController中的搜索查询字符串,objective-c,uisearchbar,uisearchcontroller,uisearchbardelegate,uisearchresultscontroller,Objective C,Uisearchbar,Uisearchcontroller,Uisearchbardelegate,Uisearchresultscontroller,我无法以编程方式重置/替换搜索查询字符串。我试图从UISearchControllerDelegate中修改UISearchBar查询字符串 我使用听写输入法 当发出命令“删除”时,应将searchController.searchBar.text设置回@”“。对于空字符串,语音检测应继续正常进行 查询字符串确实被重置为@“,但语音检测停止 如何以编程方式重置UISearchController中的搜索查询字符串,并且仍然能够使用语音继续输入 - (void)updateSearchResult

我无法以编程方式重置/替换搜索查询字符串。我试图从UISearchControllerDelegate中修改UISearchBar查询字符串

我使用听写输入法

当发出命令“删除”时,应将
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中尚不可用。当您试图清除搜索栏文本字段中的文本时,它会将键盘模式更改为键盘输入

因此,结论是,您只能使用听写向textField提供输入,但无法清除它。用户必须手动执行此过程才能再次更改为听写输入


希望有帮助。

同样的结论,不支持也不可能从代码中重新激活语音输入。