Swift:多个类的一个webview

时间:2015-11-21 00:37:05

标签: ios swift webview

是否可以使用一个webview并使用Swift调用多个类?

我试图从一个UIAlertController中调用JavaScript,该UIAlertController是在一个单独的类中创建的,用于处理回调。我发现我只能在运行时才能这样做

func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {

    //This calls the JavaScript but does so automatically and only from the ViewController where the webview is created.        
    Webview.stringByEvaluatingJavaScriptFromString("CallToJS(true)")

}

我发现当我为一个对象创建一个@IBAction并使用回调处理程序将UIAlertController放在另一个类中时,我也可以使它工作。

0 个答案:

没有答案
相关问题