gpt4 book ai didi

ios - 在 iOS 中按下按钮即可使用 textView 进行 Google 搜索

转载 作者:行者123 更新时间:2023-11-29 04:44:58 24 4
gpt4 key购买 nike

我正在自定义一个开源 QR 阅读器,以从 TextView 中获取文本,然后进行 Google 搜索或在浏览器中打开文本。该客户坚持只使用 Google 搜索。

我有两个按钮。 “谷歌”和“网络”。代码表明了它们的工作原理。

我正在考虑将“http//www.google.com/search='”附加到“resultText.text'”但我不知道如何使用谷歌搜索来做到这一点的正确格式。

到目前为止我必须执行此操作的代码是:

- (IBAction)openBrowser :(id)sender
{
if ([[sender currentTitle] isEqualToString:@"Google"]) {

NSURL *url = [NSURL URLWithString:resultText.text];
[[UIApplication sharedApplication] openURL:url];

}
else if([[sender currentTitle] isEqualToString:@"Web"]){
NSURL *url = [NSURL URLWithString:resultText.text];
[[UIApplication sharedApplication] openURL:url];
}
}

我尝试用谷歌搜索这个,但正如你可以想象的那样,结果与我正在寻找的结果相差甚远。我不断从最近的新闻中获得 Google/Apple 搜索栏的头条新闻。

干杯!

最佳答案

经过更广泛的搜索,我找到了自己问题的答案。

http://www.our-picks.com/archives/2007/01/30/google-search-urls-revealed-or-how-to-create-your-own-search-url/

这是我添加的代码:

if ([[sender currentTitle] isEqualToString:@"Google"]) {
NSMutableString *googleUrl = [[NSMutableString alloc] initWithString:@"http//www.google.com/search?q="];
[googleUrl appendString:resultText.text];

NSURL *url = [NSURL URLWithString:googleUrl];
[[UIApplication sharedApplication] openURL:url];

}

关于ios - 在 iOS 中按下按钮即可使用 textView 进行 Google 搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9789764/

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