如何从URL方案中获取参数。 [英] How to take the parameter from URL scheme.

查看:104
本文介绍了如何从URL方案中获取参数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的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 app At 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方案中获取参数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆