`
johnie_sheng
  • 浏览: 110346 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

在一个应用程序中其他的应用,比如说网站,App Store等等

 
阅读更多

在一个应用程序中启动其他的服务是用方法: UIApplication:openURL

这里罗列了七种服务可以被启动:

1, Browse

2, Google Maps

3, Apple Mail

4, Phone Call

5, SMS Application

6, App Store

 

1, Browse

 

NSURL
 *
url =
 [
NSURL
 URLWithString:
@
"http://www.iphonedevelopertips.com"
]
;
[
[
UIApplication sharedApplication]
 openURL:
url]
;

2, Google Maps

格式:http://maps.google.com/maps?q=${QUERY_STRING}

// Create your query ...

NSString
*
 searchQuery =
 @
"1 Infinite Loop, Cupertino, CA 95014"
;
 
// Be careful to always URL encode things like spaces and other symbols that aren't URL friendly

searchQuery =
  [
addressText stringByAddingPercentEscapesUsingEncoding:
 NSUTF8StringEncoding]
;
 
// Now create the URL string ...

NSString
*
 urlString =
 [
NSString
 stringWithFormat:
@
"http://maps.google.com/maps?q=%@"
, searchQuery]
;
 
// An the final magic ... openURL!

[
[
UIApplication sharedApplication]
 openURL:
[
NSURL
 URLWithString:
urlText]
]
;

3, Apple Mail

格式:mailto://${EMAIL_ADDRESS}

[
[
UIApplication sharedApplication]
 openURL:
[
NSURL
 URLWithString:
@
"mailto://info@iphonedevelopertips.com"
]
]
;

4, Phone Call(只是对iPhone)

[
[
UIApplication sharedApplication]
 openURL:
[
NSURL
 URLWithString:
@
"tel://8004664411"
]
]
;

5, SMS Application

[
[
UIApplication sharedApplication]
 openURL:
[
NSURL
 URLWithString:
@
"sms:55555"
]
]
;

6, App Store

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics