swift - 单击UIWebView中的按钮打开ViewController

时间:2018-02-20 18:12:02

标签: javascript swift

我有一个名为“test123”的ViewController,我有一个带有按钮的UIWebView:

<button onclick='myFunction()'>Open test123</button>
</body>

<script>
    function myFunction()
    {
        presentViewController('test');

    }
    </script>

我尝试了this,但我得到了Use of undeclared type 'test123'

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

    if (navigationType == UIWebViewNavigationType.formSubmitted) {
        let VC = self.storyboard?.instantiateViewControllerWithIdentifier("test123") as? test123

        let navigationController = UINavigationController(rootViewController: VC!)
        self.navigationController?.presentViewController(navigationController, animated: true, completion:nil)


    }
    return true
}

那么我做错了什么?

1 个答案:

答案 0 :(得分:0)

您应该将尝试向下转换对象的as? test123部分移除到显然不存在的类型test123