我有一个名为“ 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
部分。