Opening ViewController when click on button in UIWebView swift

后端 未结 2 1290
日久生厌
日久生厌 2021-02-06 17:34

I Have an app which has UIWebView and the Webview contains simple Button

and here\'s my WebViewController :

import UIKit

class testV         


        
2条回答
  •  不要未来只要你来
    2021-02-06 17:55

    Yes you can do that like this :

    func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
            
            if (navigationType == UIWebViewNavigationType.FormSubmitted) {
                let VC = self.storyboard?.instantiateViewControllerWithIdentifier("myViewControllerName") as? myViewControllerName
    
                let navigationController = UINavigationController(rootViewController: VC!)
                self.navigationController?.presentViewController(navigationController, animated: true, completion:nil)
    
        
            }
            return true
        }
    

提交回复
热议问题