shareUIApplication openURL
2011-03-06 21:25
267 查看
iPhone的单任务模式为手机节省了资源,保障了程序的安全运行,但是这一做法也遭到很多人的反对,为很多应用带来了不便。如今,openURL这个方法为解决这一问题带来了希望,虽然离多任务模式还有差距,但毕竟给了大家一个实现更强大应用的可行方法。
openURL的使用方法:
CODE:
CODE:
CODE:
1. http://iphonedevelopertips.com/c ... ne-application.html
2. http://iphonedevelopertips.com/c ... tom-url-scheme.html
openURL能帮助你运行Maps,SMS,Browser,Phone甚至其他的应用程序。这是Iphone开发中我经常需要用到的一段代码,它仅仅只有一行而已。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
这个程序通过基础的协议支持拨打电话的功能
译者附:
-(IBAction)openMaps {//打开地图
// Where is Apple on the map anyway?
NSString* addressText = @”1 Infinite Loop, Cupertino, CA 95014″;
// URL encode the spaces
addressText = [addressText stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
NSString* urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
// lets throw this text on the log so we can view the url in the event we have an issue
NSLog(urlText);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
}
-(IBAction)openEmail {//打开mail
// Fire off an email to apple support
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
}
-(IBAction)openPhone {//拨打电话
// Call Google 411
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
}
-(IBAction)openSms {//打开短信
// Text to Google SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];
}
-(IBAction)openBrowser {//打开浏览器
// Lanuch any iPhone developers fav site
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunesconnect.apple.com"]];
}
openURL的使用方法:
CODE:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appString]];其中系统的appString有:
CODE:
Map http://maps.google.com/maps?q=Shanghai Email mailto://myname@google.com Tel tel://10086 Msg sms://10086除此之外,还可以自己定义URL,方法如下:
CODE:
打开info.plist,添加一项URL types 展开URL types,再展开Item1,将Item1下的URL identifier修改为URL Scheme 展开URL Scheme,将Item1的内容修改为myapp 其他程序可通过myapp://访问此自定义URL参考资料:
1. http://iphonedevelopertips.com/c ... ne-application.html
2. http://iphonedevelopertips.com/c ... tom-url-scheme.html
openURL能帮助你运行Maps,SMS,Browser,Phone甚至其他的应用程序。这是Iphone开发中我经常需要用到的一段代码,它仅仅只有一行而已。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
这个程序通过基础的协议支持拨打电话的功能
译者附:
-(IBAction)openMaps {//打开地图
// Where is Apple on the map anyway?
NSString* addressText = @”1 Infinite Loop, Cupertino, CA 95014″;
// URL encode the spaces
addressText = [addressText stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
NSString* urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
// lets throw this text on the log so we can view the url in the event we have an issue
NSLog(urlText);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
}
-(IBAction)openEmail {//打开mail
// Fire off an email to apple support
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
}
-(IBAction)openPhone {//拨打电话
// Call Google 411
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
}
-(IBAction)openSms {//打开短信
// Text to Google SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];
}
-(IBAction)openBrowser {//打开浏览器
// Lanuch any iPhone developers fav site
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunesconnect.apple.com"]];
}
相关文章推荐
- iOS开发中使用[[UIApplication sharedApplication] openURL:]加载其它应用
- iOS UIApplication的openURL方法 -- @ShinePug
- iOS开发中使用[[UIApplication sharedApplication] openURL:]加载其它应用
- UIApplication ShareApplication 应用
- 主题 : 如何调用- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url;
- [UIApplication sharedApplication] openURL
- iOS开发中使用[[UIApplication sharedApplication] openURL:]加载其它应用
- [[UIApplication sharedApplication] openURL:]的几种应用
- UIApplication.sharedApplication().openURL的使用(Swift版)
- Iphone UIApplication openURL能帮助你运行Maps,SMS,Browser, Calling甚至其他的应用程序
- Iphone UIApplication openURL能帮助你运行Maps,SMS,Browser, Calling甚至其他的应用程序
- iOS开发中使用[[UIApplication sharedApplication] openURL:]加载其它应用
- [UIApplication sharedApplication] openURL IOS7读取缓存
- OC中APPDelegate[[UIApplication shareApplication]delegate]]Swift实现
- iOS UIApplication功能十分强大的openURL方法
- Ios 调用Appstore 下载界面 [[UIApplication sharedApplication] openURL
- [UIApplication sharedApplication] openURL 转载
- OC中APPDelegate[[UIApplication shareApplication]delegate]]Swift实现
- 解决 UIApplication openURL 慢、卡顿、长时间等待 的问题
- iOS开发中使用[[UIApplication sharedApplication] openURL:]加载其它应用