![](/img/trans.png)
[英]Swift - How do I segue with a button from ViewController to a specific TabBarController
[英]How do I present a ViewController from a button click in webView? Swift/Xcode
這是我的雨燕
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if (navigationType == UIWebViewNavigationType.formSubmitted) {
let VC = self.storyboard?.instantiateViewController(withIdentifier: "UITabBarController") as? UITabBarController
let navigationController = UINavigationController(rootViewController: VC!)
self.navigationController?.present(navigationController, animated: true, completion:nil)
}
return true
}
這是我在webView中加載的HTML文件
<html>
<head>
<script>
function myFunction()
{
presentViewController('UITabBarController');
}
</script>
</head>
<body>
<input name="myFunction" type="submit" onClick="myFunction" value="myFunction">
</body>
</html>
這只是行不通,有什么建議嗎? 我不在乎它是否也是鏈接而不是按鈕。
它是viewcontroller內的webView,單擊鏈接/按鈕后,將顯示下一個具有標簽欄的viewcontroller。
您是否嘗試過打開鏈接? 您應該收到一個func webView(UIWebView,shouldStartLoadWith:URLRequest,navigationType:UIWebViewNavigationType)委托回調。 在這里,您應該檢查鏈接是否是觸發視圖控制器打開的鏈接。 如果是特殊鏈接,則將打開viewController並返回false。 否則返回true。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.