如何在 html 按钮的单击事件上调用任何 Objective C 插件方法
我是phonegap开发的新手。我有一个 html 页面,其中包含一个文本字段和一个按钮。我想调用我的插件方法 -(void)nameOfMethod:( NSMutableArray*)paramArray withDict: (NSMutableDictionary*) options
,它位于我的插件类中,它从我的 html 文本字段获取文本并显示Alertview.我不知道如何通过 javascript 调用此方法。我在 javascript 中编写了一小部分代码,
<head><script type="text/javascript" src="encryptdata.js"></script></head>
<body>
<input type="password" name="confirmPassword" id="confirmPassword" value="" />
<input type="button" value="FetchR" onclick="fetchRelation()"/> </body>
encryptdata.js
function fetchRelation() { var getvalue=document.getElementById('confirmPassword').value; //what is next step....... to send the data to the plugin class }
但我不知道如何在 javascript 中安装该插件并在 javascript 中调用其方法。有没有人对phonegap有任何想法,请帮助我。
I am new in phonegap development. I have one html page which contains one textfield and one button. I want to call my plugin method -(void)nameOfMethod:( NSMutableArray*)paramArray withDict: (NSMutableDictionary*) options
which is inside the my plugin class and it getting text from my html text field and displaying alertview.I don't have have idea how to call this method via a javascript .I did a small part of coding in javascript
<head><script type="text/javascript" src="encryptdata.js"></script></head>
<body>
<input type="password" name="confirmPassword" id="confirmPassword" value="" />
<input type="button" value="FetchR" onclick="fetchRelation()"/> </body>
encryptdata.js
function fetchRelation() { var getvalue=document.getElementById('confirmPassword').value; //what is next step....... to send the data to the plugin class }
but i don't have idea how to install that plugin in javascript and call its method in javascript . Is there anyone have idea about phonegap then plese help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方法是将 UIWebView 委托设置为一个类并监视 -webView:shouldStartLoadWithRequest:navigationType: 方法。只需使用 window.location 向其传递 URL 或解析 URL 即可调用所需的 Objective-C 方法。
The workaround is to set the UIWebView delegate to a class and watch for the -webView:shouldStartLoadWithRequest:navigationType: method. Just pass a URL to it by using window.location or and parse the URL to call the Objective-C method you want.