使用Swift在iOS中获取Javascript函数响应 [英] Get Javascript function response in iOS using Swift

查看:267
本文介绍了使用Swift在iOS中获取Javascript函数响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清楚如何使用swift平台在我的iOS应用程序中实现 JavaScript函数

I am trying to figure out how to implement JavaScript functions inside my iOS app using swift platform .


我已经尝试了链接中指定的示例代码

I have tried out the example code specified in the link

https://tetontech.wordpress.com/2014/07/15/swift-to-javascript-and-javascript-to-swift-a-round-trip/

但是我想要像 android 一样按照链接 http://android-er.blogspot.in/2011/10/call-javascript-inside-webview -from.html

But i want in the same way like android is doing as specified in the link http://android-er.blogspot.in/2011/10/call-javascript-inside-webview-from.html

你能不能帮助我。

任何帮助都会深深感激。

Any help will deeply appriciated.

推荐答案

如果您使用 WKWebView ,可以使用javascript调用javascript

If you are using WKWebView you can call javascript by using

webView.evaluateJavaScript("YourJavaScript",completionHandler : nil )

对于 UIWebView ,你可以使用

  webview.stringByEvaluatingJavascriptFromString : @"YourJavaScript";

这篇关于使用Swift在iOS中获取Javascript函数响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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