Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在swift代码中调用此javascript函数_Javascript_Ios_Swift - Fatal编程技术网

如何在swift代码中调用此javascript函数

如何在swift代码中调用此javascript函数,javascript,ios,swift,Javascript,Ios,Swift,这是webView中的javascript函数 function draft(){ var getAllHtmlCode = getHtml(); Android.fullCode(getAllHtmlCode); } 现在我想用swift代码中的参数调用这个fullcode函数 我正试着这样做 var c:String? func fullcode(getAllHtmlCode) { c = getAllHtmlCode } 您可以尝试使用

这是webView中的javascript函数

function draft(){
         var getAllHtmlCode = getHtml();
         Android.fullCode(getAllHtmlCode);
    }
现在我想用swift代码中的参数调用这个fullcode函数 我正试着这样做

var c:String?

func fullcode(getAllHtmlCode) {

c = getAllHtmlCode

}

您可以尝试使用
stringByEvaluatingJavaScript

let myJavaScript : String = "window.alert("Hello!");"
self.myWebView.stringByEvaluatingJavaScript(from: myJavaScript)
回答这个问题