在开发中,我们有的时候需要跳转到各种各样的应用,其实跳转都有一个共性,每一个跳转只需要知道协议链接就好啦
跳转到详情,评论
// 跳转到详情
NSString *str = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/cn/app/id%@?mt=8", AppId];
UIApplication *app = [UIApplication sharedApplication];
NSURL *url = [NSURL URLWithString:str];
if ([app canOpenURL:url]) {
[app openURL:url];
}
// 跳转到评论
NSString *str = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@", AppId];
UIApplication *app = [UIApplication sharedApplication];
NSURL *url = [NSURL URLWithString:str];
if ([app canOpenURL:url]) {
[app openURL:url];
}
跳转到微信
NSURL * url = [NSURL URLWithString:@"weixin://"];
BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
//先判断是否能打开该url
if (canOpen)
{ //打开微信
[[UIApplication sharedApplication] openURL:url];
}else {
}
跳转到QQ
NSURL * url = [NSURL URLWithString:@"mqq://"];
BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
//先判断是否能打开该url
if (canOpen)
{ //打开微信
[[UIApplication sharedApplication] openURL:url];
}else {
}
也可以使用UIWebView
/**
* 客服电话
*/
@property (nonatomic, strong) UIWebView *webView;
- (UIWebView *)webView
{
if(!_webView)
{
_webView = [[UIWebView alloc] initWithFrame:CGRectZero];
}
return _webView;
}
// 客服电话
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", self.lbl_Telphone.text]]]];
// 跳到QQ
NSURL *url = [NSURL URLWithString:@"mqq://"];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
// 跳到微信
NSString *str =@"weixin://";
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];