我有一个名为“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
}
那么我做错了什么?
最佳答案
您应该删除 as? test123
部分尝试将对象向下转换为显然不存在的 test123
类型。
关于javascript - swift - 通过单击 UIWebView 中的按钮打开 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48891688/