如何通过iOS应用将文本从textField传递到Google搜索? [英] How to pass text from a textField to Google Search from an iOS app?

查看:73
本文介绍了如何通过iOS应用将文本从textField传递到Google搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将字符串从我的iOS应用传递给Google搜索,以便使我能够在Safari中获取结果.

I would like to pass a string to the Google search from my iOS app, so as to enable me to fetch the results in Safari.

推荐答案

您可以执行以下操作:

var query = "hello world"
query = query.replacingOccurrences(of: " ", with: "+")
var url = "https://www.google.co.in/search?q=" + query
UIApplication.shared.open(URL(string: url)!, options: [:], completionHandler: nil)

用您的搜索字符串替换查询.

Replace query with your search string.

这篇关于如何通过iOS应用将文本从textField传递到Google搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆