一,注册自定义URL Scheme

1,找到项目的Info.plist 并打开。

 

【读书笔记】iOS-自定义URL Scheme

 

2,找到Information Property List--->右击--->Add Row--->URL types.

 

【读书笔记】iOS-自定义URL Scheme

 

3,找到URL types前面的小三角——>点击小三角,将其展开--->找到Item0前面的小三角--->点击小三角,将其展开--->看到URL identifier.

我们一般将URL identifier的值设置为Bundle identifier的值。

 

【读书笔记】iOS-自定义URL Scheme

 

 

4,找到Bundle identifer,双击标题---->复制Bundle identifier的值。

 

【读书笔记】iOS-自定义URL Scheme

 

5,找到URL identifier--->双击标题---->粘贴。

 

 

【读书笔记】iOS-自定义URL Scheme

 

6,找到Item0---->右击-->Add Row---->URL Schemes--->如图所示。

 

【读书笔记】iOS-自定义URL Scheme

 

 

 

7,展开URL Schemes的小三角。找到Item0.

 

【读书笔记】iOS-自定义URL Scheme

 

8,将Item0设置为cityguide.

 

【读书笔记】iOS-自定义URL Scheme

 

9,使用自定义URL Scheme.

 

 

URL identifier 是打开的应用的标记。

URL Scheme  是写代码中需要用的,只需要在后面加上://则可使用。 

 

 

NSString *string=@"cityguide://London";

NSURL *url=[NSURL URLWithString:string];

[[UIApplication shareApplication] openURL:url];

 

 

参考资料:《iOS编程指南》

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-10-09
猜你喜欢
  • 2022-12-23
  • 2022-01-11
  • 2021-11-10
  • 2021-09-19
  • 2021-07-20
相关资源
相似解决方案