- 浏览: 110498 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
huaweiAt_888:
再cmd运行么?我的怎么没有?
SVN -
johnie_sheng:
用个条件语句,比如说#if TARGET_OS_IPHONEA ...
编译错误:expected specifier-qualifier-list before ‘class' -
ann_iphone:
能不能请教一下博主如何让AVCaptureSession类在s ...
编译错误:expected specifier-qualifier-list before ‘class' -
ext:
还是3.2的xcode 好哈一个rename 搞定。。
Xcode修改项目名 -
zhoujj303030:
看这样的文章对我来说有压力啊!不过还是勉强看下去!
如何避免SVN运行时老是输入密码
In an earlier post
I talked about how to launch the browser from within an iPhone application using the UIApplication:openURL:
method.
It is also possible to use this same technique to launch other applications on the iPhone that are very useful.
Examples of some of the key applications that you can launch via URL are:
- Launch Google Maps
- Launch Apple Mail
- Dial a Phone Number
- Launch the SMS Application
- Launch the Browser
- Launch the AppStore
Launch Google Maps
The URL string for launching Google Maps with a particular keyword follows this structure:
http://maps.google.com/maps?q=${QUERY_STRING}
The only trick to this is to ensure that the value for the ${QUERY_STRING} is properly URL encoded. Here is a quick example of how you would launch Google Maps for a specific address:
1 2 3 4 5 6 7 8 9 10 11 |
// Create your query ... NSString * searchQuery = @ "1 Infinite Loop, Cupertino, CA 95014" ; // Be careful to always URL encode things like spaces and other symbols that aren't URL friendly searchQuery = [ addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding] ; // Now create the URL string ... NSString * urlString = [ NSString stringWithFormat: @ "http://maps.google.com/maps?q=%@" , searchQuery] ; // An the final magic ... openURL! [ [ UIApplication sharedApplication] openURL: [ NSURL URLWithString: urlText] ] ; |
Launch Apple Mail
Also very useful, is the ability to enable a user to quickly send an email by launching the email client in compose mode and the address already filled out. The format of this URI should be familiar to anyone that has done any work with HTML and looks like this:
mailto://${EMAIL_ADDRESS}
For example, here we are opening the email application and filling the “to:” address with info@iphonedevelopertips.com :
[ [ UIApplication sharedApplication] openURL: [ NSURL URLWithString: @ "mailto://info@iphonedevelopertips.com" ] ] ;
Dial a Phone Number (iPhone Only)
You can use openURL:
to dial a phone number. One
advantage this has over other URLs that launch applications, is that the
dialer will return control back to the application when the user hits
the “End Call” button.
Anyone familiar with J2ME or WML will find this URL scheme familiar:
tel://${PHONE_NUMBER}
Here is an example of how we would dial the number (800) 867-5309:
1 |
[ [ UIApplication sharedApplication] openURL: [ NSURL URLWithString: @ "tel://8004664411" ] ] ; |
NOTE When providing an international number you will need to include the country code.
Launch the SMS Application
Also not supported by the iPod Touch, is the ability to quickly setup the SMS client so that your users can quickly send a text message. It is also possible to provide the body of the text message.
The format looks like this:
sms:${PHONENUMBER_OR_SHORTCODE}
NOTE: Unlike other URLs, an SMS url doesn’t use the “//” syntax. If you add these it will assume it is part of the phone number which is not.
1 |
[ [ UIApplication sharedApplication] openURL: [ NSURL URLWithString: @ "sms:55555" ] ] ; |
NOTE: According to the official SMS specification, you should be able to send a body as well as the phone number by including “?body=” parameter on the end of the URL … unfortunately Apple doesn’t seem to support this standard.
Lauching Browser
Here is a simple example of how to open safari with a specific URL:
1 2 |
NSURL * url = [ NSURL URLWithString: @ "http://www.iphonedevelopertips.com" ] ; [ [ UIApplication sharedApplication] openURL: url] ; |
Launching the AppStore
Finally, it is worth noting that you can launch the AppStore and have the "buy" page of a specific application appear. To do this, there is no special URL scheme. All you need to do is open up iTunes to the application you want to launch; right-click on the application icon at the top left of the page; and select Copy iTunes Store URL .
The URL will look something like this:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8
Launching the AppStore URL is exactly the same as you would launch the browser. Using the link above, here is an example of how we would launch the AppStore:
1 2 |
NSURL * appStoreUrl = [ NSURL URLWithString: @ "http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8" ] ; [ [ UIApplication sharedApplication] openURL: appStoreUrl] ; |
发表评论
-
iOS 应用程序目录结构
2016-03-16 13:36 396iOS应用程序采用的是沙盒原理设计,普及一下知识:沙盒是在 ... -
Effective ObjectiveC 2.0读书笔记第一章:熟悉ObjectiveC
2016-01-25 10:51 369Objective-C通过一套全新语法,在C语言基 ... -
Swift学习
2016-01-24 11:08 457从今天开始系统学习Swift,并且把学习的源代码放在Git ... -
iOS的UILable一行显示多样字符
2016-01-22 15:45 356要现实AABBBBB的效果: NS ... -
拉伸设置按钮的图片
2016-01-22 11:12 476为了减小应用的大小,可以拉伸的图片是没有必要放全图的。 ... -
拉伸设置按钮的图片
2016-01-22 11:06 0为了减小应用的大小,可以拉伸的图片是没有必要放全图的。 ... -
拉伸设置按钮的图片
2016-01-22 11:06 0为了减小应用的大小,可以拉伸的图片是没有必要放全图的。 下 ... -
10大iOS开发者最喜爱的类库
2013-08-13 14:38 1386库是开发的根本,从页 ... -
做了款数独应用来练练脑子
2013-06-11 20:53 689<!--?xml version="1.0& ... -
一个简单的Cocos2d例子
2012-12-10 15:57 898一个简单的cocos2d的例子,一个自动旋转的球上面趴着五只小 ... -
AVAudioPlayer 简单例子
2012-12-10 15:34 664包括循环播放以及背景播放,满足一般朋友的需求。 包含一 ... -
UIScrollView的性能问题
2012-12-10 15:32 820Coming Soon ...... -
CGGeometry中的方法
2011-12-07 11:43 3237CGGeometry中的方法 Creating ... -
在一个应用程序中其他的应用,比如说网站,App Store等等
2011-07-13 10:27 952在一个应用程序中启动其他的服务是用方法: UIApplicat ... -
是否该用 Core Data?
2011-06-29 11:39 1737Core Data 是 Cocoa 里面一套非常受欢迎 ... -
实用iOS Apps
2011-05-13 16:45 7781。免费电话 Viber 2。360拍照 Photosynt ... -
iPhone-NSAssert使用
2011-05-12 20:11 2399调试cocoa程序在程序出 ... -
Workspace & static library
2011-04-28 19:04 876http://blog.boreal-kiss.net/201 ... -
constrainedToSize计算String的height
2011-03-23 17:53 1367CGSize titleSize = [aString siz ... -
Programming with Subversion, Trac and Buildbot
2011-03-21 20:41 801http://olivier.ramonat.free.fr/ ...
相关推荐
C#调用其他应用程序,其中有用户权限,管理员权限.
如何在VB6.0应用程序中调用Exce12000,供大家参考
ios一个app应用内部调用另一个新的app应用,ios app内调用另一个app app打开新app
存储过程- 06.在应用程序中调用存储过程 资源多多只取三分
本教程是继使用HttpClient调用Web API只有的补充教程,主要讲解了如何在WPF中异步调用Web API且不阻塞主线程。
C#跨应用程序调用。项目可以启动其他程序获取输出。
wince下应用程序如何调用驱动程序,关于流驱动的部分代码。
app-app-calling-android, 使用本教程构建应用Android调用应用程序的应用程序 #Build 一个简单的Android VoIP呼叫应用程序,带有 Sinch本教程将指导你构建一个简单的Android VoIP呼叫应用程序。 完成后,它将显示...
应用程序调用 USB 驱动程序,好东西!
2、解压后有两个文件,一个为scull文件夹,一个为App.c; 3、进入scull文件夹后,执行make可进行编译,编译成功了,加载scull 模块(执行命令./scull_load); 4、编译应用程序App.c(gcc -o App.o App.c); 5、执行...
C#实现在窗体调用其他的.exe应用程序
web调用本地应用程序
Android APP间授权登录(无需SDK类似微信登录),A_APP通过Uri调用B_APP(Uri含两个应用包)demo
利用Struts 2框架创建一个web项目chap2_e22,实现用户登录过程。具体要求是在loginAction类中分别用login()和registered()处理用户登录和注册的过程,分别创建login.jsp和register.jsp两个页面实现登录和注册的...
powerbuilder中实例25 调用Windows应用程序,适合初学者
VB之精彩编程参阅资料-怎样用VB在应用程序中调用API
CVI中如何调用第三方的应用程序,及打开网页,系统应用程序等,包含打开的应用程序是否是最大化
在应用内升级主要是通过调用服务器端接口获取应用的升级信息,然后通过获取的服务器升级应用信息与本地的 App 版本比对,若服务器下发的最新的 App 版本高于本地的版本号,则说明有新版本发布,那么我们就可以执行...
windows;JS;exe;打开应用程序