WKWebView loadFileURL works only once

后端 未结 3 1882
醉梦人生
醉梦人生 2021-02-19 16:18

I need to load a local file in a WKWebView. I\'m using the new ios9 method

- (nullable WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)re

3条回答
  •  悲&欢浪女
    2021-02-19 16:43

    I also encountered this problem. What worked for me is to simply to refresh the UIView container holding the webView:

    [webView loadFileURL:url allowingReadAccessToURL:[url URLByDeletingLastPathComponent]];
    [webViewContainer setNeedsDisplay];
    [webViewContainer setNeedsLayout];
    

    Hope this helps.

提交回复
热议问题