UIApplication有个功能十分强大的openURL:方法
- (BOOL)openURL:(NSURL*)url;
URL:一个资源的唯一路径
URL的组成 = 协议头://主机域名/路径
网络资源URL的组成 = http(s)://www.baidu.com/images/1.png
本地资源URL的组成 = file:///Users/apple/Desktop/1.png(注意file:后面是3个斜杆,因为本地资源的主机域名不用写,所以。。。)
openURL:方法的部分功能有
打电话
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[NSURL URLWithString:@"tel://10086"]];
发短信
[app openURL:[NSURL URLWithString:@"sms://10086"]];
发邮件
[app openURL:[NSURL URLWithString:@"mailto://12345@qq.com"]];
打开一个网页资源(会自动判断,如果是网络资源,启动Sufari进行访问)
[app openURL:[NSURL URLWithString:@"http://ios.itcast.cn"]];
打开其他app程序