1.根据url打开safari打开指定网页
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://www.diyvc.com"]]
2.在xcode之中,我们可以为每个app都指定其url
在target->info->URL TYPES中进行添加,可以对url scheme进行设置,如qcd。
在浏览器中输入"qcd://"即可打开指定的app;通过1中的函数可以实现从一个app跳转到另一个app。
3.可以传参给其他app
在“qcd://”后可以添加参数,如以下形式:qcd://name:1xd//sex:male。
在appdelegate.m中添加如下函数,并可以在其中对url内的参数进行处理:
-(BOOL)application:(UIApplication *)application handleOpenUrl:(NSURL *)url{
if(!url){
return NO;
}
NSString *urlStr = [url absoluteString];
//自行处理url中的参数
return YES;
}