ios URL Scheme

原文链接:http://blog.youkuaiyun.com/reylen/article/details/8424150

Add Row  URL types,然后按照上面的设置,URL identifier   自定义,item(todolist部分) 自定义;

上面显示item1实际为item0;

下面的为接收到外部调用的时候程序启动,响应方法,在safari输入:todolist://com.acme.ToDoList ,

  1. - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {  
  2.       
  3.     if ([[url scheme] isEqualToString:@"todolist"]) {  
  4.         NSLog(@"外部调用成功");  
  5.     }  
  6.     return YES;  
  7. }  

下面的为自身调用safari浏览器,运行谷歌地图:

  1. NSString* searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";  
  2. searchQuery = [addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];  
  3. NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery];  
  4. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];  


  1. 调用谷歌地图(Google Maps)  
  2.   
  3. URL模式:http://maps.google.com/maps?q=<strong>${QUERY_STRING}</strong>  
  4. 代码示例:  
  5.   
  6. NSString* searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";  
  7. searchQuery = [addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];  
  8. NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery];  
  9. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];  
  10.   
  11.    
  12.   
  13. 调用邮件客户端(Apple Mail)  
  14.   
  15. URL模式:mailto://<strong>${EMAIL_ADDRESS}</strong>  
  16. 代码示例:  
  17.   
  18. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@eyecm.com"]];  
  19.   
  20.    
  21.   
  22. 拨号(Phone Number)  
  23.   
  24. URL模式:tel://<strong>${PHONE_NUMBER}</strong>  
  25. 代码示例:  
  26.   
  27. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];  
  28.   
  29.    
  30.   
  31. 调用短信(SMS)  
  32.   
  33. URL模式:sms:<strong>${PHONENUMBER_OR_SHORTCODE}</strong>  
  34. 代码示例:  
  35.   
  36. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:10086"]];  
  37.   
  38.    
  39.   
  40. 调用浏览器(Safari Browser)  
  41.   
  42. 代码示例:  
  43.   
  44. NSURL *url = [NSURL URLWithString:@"http://eyecm.com"];  
  45. [[UIApplication sharedApplication] openURL:url];  
  46.   
  47.    
  48.   
  49. 调用应用商店(AppStore)  
  50.   
  51. URL模式:http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8  
  52. 代码示例:  
  53.   
  54. NSURL *appStoreUrl = [NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&amp;mt=8"];  
  55. [[UIApplication sharedApplication] openURL:appStoreUrl];  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值