openURL的使用方法

来源:互联网 发布:淘宝店售假还能救活吗 编辑:程序博客网 时间:2024/06/05 20:33

openURL的使用方法

 

openURL的使用方法

view plaincopy to clipboardprint?
  1. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:appString]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appString]];

其中系统的appString有:

view plaincopy to clipboardprint?
  1. Map http://maps.google.com/maps?q=Shanghai
  2. Email mailto://myname@google.com
  3. Tel tel://10086
  4. Msg sms://10086
Map http://maps.google.com/maps?q=Shanghai

Email mailto://myname@google.com

Tel tel://10086

Msg sms://10086

除此之外,还可以自己定义URL,方法如下:

view plaincopy to clipboardprint?
  1. 打开info.plist,添加一项URL types
  2. 展开URL types,再展开Item1,将Item1下的URL identifier修改为URL Scheme
  3. 展开URL Scheme,将Item1的内容修改为myapp
  4. 其他程序可通过myapp://访问此自定义URL
打 开info.plist,添加一项URL types 展开URL types,再展开Item1,将Item1下的URL identifier修改为URL Scheme 展开URL Scheme,将Item1的内容修改为myapp 其他程序可通过myapp://访问此自定义URL

参考资料:

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo}

http://iphonedevelopertips.com/cocoa/launching-other-apps-within-an-iphone-application.html

openURL能帮助你运行MapsSMSBrowser,Phone甚至其他的应用程序。这是Iphone开发中我经常需要用到的一段代码,它仅仅只有一行而已。

view plaincopy to clipboardprint?
  1. - (IBAction)openMaps {
  2. //打开地图
  3. NSString *addressText = @"beijing";//@"1 Infinite Loop, Cupertino, CA 95014";
  4. addressText = [addressText stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
  5. NSString *urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
  6. NSLog(@"urlText =============== %@", urlText);
  7. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
  8. }
- (IBAction)openMaps {
//打开地图
NSString *addressText = @"beijing";
//@"1 Infinite Loop, Cupertino, CA 95014";
addressText = [addressText stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString *urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
NSLog(@"urlText =============== %@", urlText);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
}

view plaincopy to clipboardprint?
  1. - (IBAction)openEmail {
  2. //打开mail
  3. // Fire off an email to apple support
  4. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
  5. }
- (IBAction)openEmail {
//打开mail // Fire off an email to apple support
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
}
view plaincopy to clipboardprint?
  1. - (IBAction)openPhone {
  2. //拨打电话
  3. // Call Google 411
  4. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
  5. }
- (IBAction)openPhone {

//拨打电话
// Call Google 411
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
}
view plaincopy to clipboardprint?
  1. - (IBAction)openSms {
  2. //打开短信
  3. // Text to Google SMS
  4. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];
  5. }
- (IBAction)openSms {
//打开短信
// Text to Google SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];
}
view plaincopy to clipboardprint?
  1. -(IBAction)openBrowser {
  2. //打开浏览器
  3. // Lanuch any iPhone developers fav site
  4. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunesconnect.apple.com"]];
  5. }
-(IBAction)openBrowser {
//打开浏览器
// Lanuch any iPhone developers fav site
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunesconnect.apple.com"]];
}
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 一岁宝宝胃胀气怎么办 3岁宝宝腹胀呕吐怎么办 胃胀气想吐怎么办快速 胃胀然后吐了怎么办 1岁宝宝胃胀气怎么办 孩子胃胀气还吐怎么办 肚子里进了凉气怎么办 肠胃涨气肚子变大怎么办 感觉肚子胀胀的怎么办 肚子胀撑的难受怎么办 肚子着凉了很疼怎么办 来月经肚子疼怎么办最快的方法 孕妇上大便有血怎么办 做完爱小腹坠痛怎么办 月经不来肚子胀怎么办 月经期间肚子疼的厉害怎么办 大姨吗来了肚子疼该怎么办 孕妇7个月拉肚子怎么办 胃疼肚子也疼怎么办 6个月孕妇肚子疼怎么办 孕妇4个月肚子疼怎么办 孕妇5个月拉肚子怎么办 4个月孕妇拉肚子怎么办 怀孕5个月拉肚子怎么办 肠胃老是胀气很不舒服怎么办 肚子里有气排不出来怎么办 小兔子不吃兔粮怎么办 泰迪肚子一直叫怎么办 狗狗肚子响该怎么办 狗狗肚子一直响怎么办 一刮风空调就响怎么办 胃里有气往上顶怎么办 胃里难受想吐怎么办 胃里感觉有水怎么办 喉咙总有气堵着怎么办 胃难受恶心想吐怎么办 胃里有气怎么办总放屁 肚子里有气很痛怎么办 胃有气排不出来怎么办 狗狗又吐又拉稀怎么办 狗吐了又拉稀怎么办