iOS应用之间调用

//
//  iOS应用之间调用.h
//  IOS笔记



1。判断系统里是否安装了某个app。好比新浪微博应用注册了URL scheme为@"weibo",咱们能够经过
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"weibo://"]]来判断系统里是否发装了新浪微博。
2。从一个应用里启动另外一个应用。能够经过接口
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"weibo://"]]来启动微博。
参数要根据微博里规定的方式传递,通常就像http的get方式传参同样。
固然启动之后,本身的应用就会退到后台,想要再切回来,就要在本身的应用里也注册URL scheme。作为回调参数传给微博app。



NSURL *url = [NSURL URLWithString:@"http://QZone.qq.com"];

if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
} else {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"message" message:[NSString stringWithFormat:@"%@",url] delegate:self cancelButtonTitle:@"肯定" otherButtonTitles:nil, nil];
    [alertView show];
}app

相关文章
相关标签/搜索