一,使用样例
2,打开百度地图
二,常见应用的URL Scheme
1,系统默认应用
2,常用第三方软件
常用的第三方应用都定义了不同的
URL Scheme,我们通过
UIApplication.sharedApplication().openURL() 方法打开相应的链接,即可跳转到对应的
App 中。
1,打开淘宝
下面样例点击按钮后,会自动跳转到淘宝App中。由于我们还传递了一个商品链接参数,那么跳转过来后就会自动打开该商品页面。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import
UIKit
class
ViewController
:
UIViewController
{
override
func
viewDidLoad() {
super
.viewDidLoad()
}
@IBAction
func
click(sender:
AnyObject
) {
let
url =
NSURL
(string: urlString)
UIApplication
.sharedApplication().openURL(url!)
}
override
func
didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
}
|
下面样例点击按钮后,会自动跳转到百度地图App中。由于我们还传递了地址作为参数,那么跳转过来后就会自动定位到该位置。
(注意:由于参数中带有中文,我们这里使用
stringByAddingPercentEncodingWithAllowedCharacters 方法对其转义一下。)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import
UIKit
class
ViewController
:
UIViewController
{
override
func
viewDidLoad() {
super
.viewDidLoad()
}
@IBAction
func
click(sender:
AnyObject
) {
let
encodeUrlString = urlStr.stringByAddingPercentEncodingWithAllowedCharacters(
.
URLQueryAllowedCharacterSet
())!
let
url =
NSURL
(string: encodeUrlString)
UIApplication
.sharedApplication().openURL(url!)
}
override
func
didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
}
|
名称 | URL Scheme | Bundle identifier |
Safari | http:// | |
maps | http://maps.google.com | |
Phone | tel:// | |
SMS | sms:// | |
mailto:// | ||
iBooks | ibooks:// | |
App Store | itms-apps://itunes.apple.com | |
Music | music:// | |
Videos | videos:// |
名称 | URL Scheme | Bundle identifier |
mqq:// | ||
微信 | weixin:// | |
腾讯微博 | TencentWeibo:// | |
淘宝 | taobao:// | |
支付宝 | alipay:// | |
微博 | sinaweibo:// | |
weico微博 | weico:// | |
QQ浏览器 | mqqbrowser:// | com.tencent.mttlite |
uc浏览器 | dolphin:// | com.dolphin.browser.iphone.chinese |
欧朋浏览器 | ohttp:// | com.oupeng.mini |
搜狗浏览器 | SogouMSE:// | com.sogou.SogouExplorerMobile |
百度地图 | baidumap:// | com.baidu.map |
Chrome | googlechrome:// | |
优酷 | youku:// | |
京东 | openapp.jdmoble:// | |
人人 | renren:// | |
美团 | imeituan:// | |
1号店 | wccbyihaodian:// | |
我查查 | wcc:// | |
有道词典 | yddictproapp:// | |
知乎 | zhihu:// | |
点评 | dianping:// | |
微盘 | sinavdisk:// | |
豆瓣fm | doubanradio:// | |
网易公开课 | ntesopen:// | |
名片全能王 | camcard:// | |
QQ音乐 | qqmusic:// | |
腾讯视频 | tenvideo:// | |
豆瓣电影 | doubanmovie:// | |
网易云音乐 | orpheus:// | |
网易新闻 | newsapp:// | |
网易应用 | apper:// | |
网易彩票 | ntescaipiao:// | |
有道云笔记 | youdaonote:// | |
多看 | duokan-reader:// | |
全国空气质量指数 | dirtybeijing:// | |
百度音乐 | baidumusic:// | |
下厨房 | xcfapp:// |
原文出自: www.hangge.com 转载请保留原文链接: http://www.hangge.com/blog/cache/detail_1141.html