1、新建两个项目:Test01,Test02;
2、分别在其属性列表中添加截图如下:
Test01
Test02
分别实现代码:
Test01的 viewController.m 中添加代码:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSURL *url = [NSURLURLWithString:@"Test01:"];
if ([[UIApplicationsharedApplication] canOpenURL:url])
{
NSLog(@"canOpenURL");
[[UIApplication sharedApplication] openURL:url];
} else
{
NSLog(@"can not OpenURL");
}
}
分别实现代码:
Test02的 viewController.m 中添加代码:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesBegan");
NSURL *url = [NSURLURLWithString:@"Test02:"];
if ([[UIApplicationsharedApplication] canOpenURL:url])
{
NSLog(@"canOpenURL");
[[UIApplication sharedApplication] openURL:url];
} else
{
NSLog(@"can not OpenURL");
}
}