openURL的使用方法

来源:互联网 发布:python 累计分布函数 编辑:程序博客网 时间:2024/06/05 19:23
1、调用 电话phone
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://800888"]]; 
拨打电话之后不跳转回app
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://800888"]]; 
拨打电话之后跳转回app


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

其中系统的appString有:
Map    http://maps.google.com/maps?q=Shanghai
Email  mailto://myname@google.com
Tel    tel://10086
Msg    sms://10086


loadFlickrKML:

maps://?f=q&hl=en&geocode=&q=http://api.flickr.com/services/feeds/geo/us/&format=kml_nl&ie=UTF8&z=1


还可以自己定义URL,方法如下:
 
打开info.plist,添加一项URL types
展开URL types,再展开Item1,将Item1下的URL identifier修改为URL Scheme
展开URL Scheme,将Item1的内容修改为myapp

其他程序可通过myapp://访问此自定义URL


调用应用商店(AppStore)

URL模式:http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8

代码示例:

NSURL*appStoreUrl= [NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8"];
[[UIApplication sharedApplication] openURL:appStoreUrl];


调用appstore评分(AppStore)

  很多用户用了好软件后忘记或嫌麻烦而不去 App Store 进行打分评星,为此开发者可以在应用中加入打分按钮,点击后直接跳转到 App Store 的评分界面。

   App Store 上评论的链接地址是 itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=appID

   所以可以用这段代码

        NSString *str = [NSString stringWithFormat:
                         @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",
                         m_appleID ];  
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

 只需要将id替换成你自己的appid即可

0 0
原创粉丝点击