我正在处理以下代码,并尝试在页面加载时在视图中显示活动指标.
我试图实现WKNavigationDelegate方法,但是我没有显示出来.
关于如何解决这个问题的任何建议?
我没有在任何地方设置SupportWebView视图委托,但我不知道如何在swift ..
import UIKit import WebKit class SupportWebView: UIViewController,WKNavigationDelegate { @IBOutlet var containerView : UIView? = nil var webView: WKWebView? override func loadView() { super.loadView() self.webView = WKWebView() self.view = self.webView } override func viewDidLoad() { super.viewDidLoad() var dataManager = DataManager.sharedDataManager() var url = dataManager.myValidURL var req = NSURLRequest(URL:url!) self.webView!.loadRequest(req) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func webView(webView: WKWebView,didStartProvisionalNavigation navigation: WKNavigation!) { UIApplication.sharedApplication().networkActivityIndicatorVisible = true } func webView(webView: WKWebView,didFinishNavigation navigation: WKNavigation!) { UIApplication.sharedApplication().networkActivityIndicatorVisible = false } }
解决方法
已经评论过,你忘了设置webView代理:
override func loadView() { super.loadView() self.webView = WKWebView() self.webView.navigationDelegate = self self.view = self.webView }