如何使用 xcode 连接或打开另一个应用程序?
现在..我正在制作一个程序..但我想让该程序连接到另一个应用程序或让一个应用程序在我的应用程序中运行..例如,当人们想要注册我的应用程序时,我想打开safari应用程序或者让它在我的应用程序中运行?我怎样才能这样做呢?有人帮我提供示例代码吗?
或者例如,在 yelp 中,单击某个按钮将打开谷歌地图应用程序,并指向从我们的位置到下一个位置的方向,
我该怎么做?
now.. I was making a program.. but I want to make the program connected to another application or make an application running in my application.. such as, when people want to sign up to my application, I want to open safari application or make it running in my application? how can I do so? is there anyone help me with a sample code?
Or for example, in yelp, clicking some button will open google map application and point direction from our location to the next
how would I do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取决于您的平台。对于 OSX,
NSAppleScript
是您的解决方案。它允许您与其他可编写脚本的程序(如 Safari、iTunes、Finder 等)进行交互。对于 iPhone,您的问题之前已被提出/回答:从 iPhone 打开 Google 地图并显示路线
Depends on your platform. For OSX,
NSAppleScript
is your solution. It allows you to interact with other scriptable programs like Safari, iTunes, Finder, etc.For iPhone, your question has been asked / answered before: Open Google Maps from iPhone and show route
如果您想要的是在 iOS 上启动任何应用程序的通用方法,则没有办法做到这一点(至少使用官方 API)。
但是,可以根据其支持的 URL 方案启动一些应用程序。
为此,您可以执行以下操作:
这将允许您打开一些本机应用程序,例如 Safari、邮件、地图、消息、App Store 等(并且根据 URL,它不仅可以打开应用程序,还可以执行一些特定于应用程序的操作)。
有一些存储库列出了本机和第三方应用程序及其已知的 URL 方案,例如:
If what you want is a generic way to launch any app on iOS, there is no way to do it (at least using the official APIs).
It is possible, however, to launch a few apps based on their supported URL schemes.
To do this, you would do something like:
This will allow you to open a few native apps like Safari, Mail, Maps, Messages, App Store, etc (and depending on the URL, it may not only open the app but also perform some app-specific action).
There are a few repositories that list both native and third-party apps and their known URL schemes, such as these: