问题描述
我在我的iPhone应用程序中使用URL方案,从我将用户切换到safari的页面,以及从网页点击按钮,我将恢复为app
那时,一些参数由网页如
I am using URL scheme in my iPhone app,from a page I switch user to safari,and a button click from Web page,I am reverting back to appAt that time ,some parameters are passed by the web page like
myapp://parameter=1
如何从我的应用程序中找到此参数?
我已经设置了一个断点
How can I find this parameter from my app ?I have placed a break point in
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)ur
但是在回复时。它没有被调用。
but while revert back.it is not get called.
推荐答案
您可以使用此 url主机
查找参数,其中参数可以是任何类型, http://
之后的任何内容或自定义标记 custom://
将在以下代码中捕获
You can use this url host
to find out the parameters, where parameters could be of any kind, anything after http://
or custom tag custom://
will be caught in the following code
NSString *urlParameter = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
如果您有多个参数,那么您可以使用 componentsSeparatedByString
分离参数的方法
If you have multiple parameters then you could use componentsSeparatedByString
method to separate the parameters
这篇关于如何从URL方案中获取参数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!