如何使用 Xcode 4 注册自定义应用程序打开 URL 方案? [英] How to register a custom app opening URL scheme with Xcode 4?

查看:32
本文介绍了如何使用 Xcode 4 注册自定义应用程序打开 URL 方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode4 要求大量参数只是为了使这个简单的事情成为可能:

Xcode4 is asking for a huge number of arguments just to make this simple thing possible:

NSString *stringURL = @"twitterriffic://";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

所有这些属性有什么用?为什么是图像?我必须在这里重复应用程序标识符吗?如果我希望任何人都能够调用此 URL 来打开我的应用程序,应该选择什么角色?这些额外的 url 类型属性有什么用?

What are all these properties for? Why an image? Must I repeat the app identifier here? What role to choose if I want anyone to be able to call this URL to open my app? And what are these Additional url type properties for?

我没有找到与 Xcode4 相关的教程,如何在 Xcode 4 中注册这样的 URL 方案.

I found no Xcode4-related tutorial how to register such an URL scheme with Xcode 4.

推荐答案

  • 打开左侧的Supporting Files"(文件夹)并点击YourAppName-Info.plist"
  • 选择像Bundle creator OS Type Code"这样的一行,然后将鼠标悬停在该行上并点击 (+) 符号
  • 这会创建一个新行并输入URL 类型"
  • 单击左侧的箭头并查看项目 0,您将项目 0 中的值重命名为URL Schemes",如图所示
  • 然后编辑第 0 项中的字段并输入您的协议;如图所示,我输入了goomzee"

现在,如果我在模拟器上安装此应用,然后打开 Safari 并在地址栏中输入goomzee://",它将启动我的应用.

Now if I install this app on my simulator, and open Safari and type "goomzee://" in the address bar it will launch my app.

这篇关于如何使用 Xcode 4 注册自定义应用程序打开 URL 方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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