//
// 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