0

WKWebView carrega o link porém não consigo realizar ação alguma no site

ViewController

import UIKit
import WebKit

class promoVC: UIViewController{

@IBOutlet weak var webView: WKWebView!

override func viewDidLoad() {
    super.viewDidLoad()


    webView.navigationDelegate = self
    webView.loadURL(strURL: "https://rh.mazza.tech/web/guest/webuser");
}

}
 extension promoVC : WKNavigationDelegate{

func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
    print(error.localizedDescription)
}

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
    print("Webview is loading")
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
    print("")
}
}
2

1 Resposta 1

0

O metodo da webView loadURL não compilala, voce precisar utilizar o método load

import UIKit
import WebKit

class ViewController: UIViewController {

@IBOutlet weak var webView: WKWebView!

override func viewDidLoad() {
    super.viewDidLoad()

    if let url = URL(string: "https://rh.mazza.tech/web/guest/webuser") {
        webView.load(URLRequest(url: url))
        webView.allowsBackForwardNavigationGestures = true
        webView.navigationDelegate = self
    }
}
}

extension ViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
     print(error.localizedDescription)
}

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
     print("Webview is loading")
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
    print("")
}
}

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .