0

Here is my Swift

     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
}

And here is my HTML file that is loaded in webView

<html>
<head>
<script>
function myFunction()
{
presentViewController('UITabBarController');
}
</script>
</head>
<body>
<input name="myFunction" type="submit" onClick="myFunction"     value="myFunction">
</body>
</html>

This just not working, any advise? I don't mind if it's a link instead of a button also.

It's webView inside viewcontroller, after clicking the Link/button, it will present a next viewcontroller which has tabbar.

1 Answer 1

1

Did you try by opening a link? You should receive a func webView(UIWebView, shouldStartLoadWith: URLRequest, navigationType: UIWebViewNavigationType) delegate callback. Here you should check if the link is the one triggering the view controller opening. If it is the special link you will open the viewController and return false. else return true.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.