[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appString]];
1、打开系统应用
打电话:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”tel://123456”]];
打开浏览器:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”http://devhc.com"]];
其他url格式如下表所示:
Apple URL Scheme Reference
Application | URI Scheme or Protocol | Query Strings |
---|---|---|
Default e-mail application | mailto:<email>?query |
Subject |
CC |
||
BCC |
||
Body |
||
Default phone application | tel:<number> |
N/A |
Default SMS application | sms:<number> |
N/A |
Syndication feed reader | feed:<url> |
N/A |
Apple FaceTime | facetime:<number> |
N/A |
2、打开自定义app
首先在要打开的比如app2中 定义在info.plist URL Schemas
在app1中打开 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@“myapp://”]]; 打开回调 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation (Available in iOS 4.2 and later) - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL*)url (ios 4.2 Deprecated)