gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 11:45:21 26 4
gpt4 key购买 nike

我有一个名为“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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com