UIWebView VS WKWebView to load local html

后端 未结 4 1094
梦如初夏
梦如初夏 2020-12-11 23:14

i create a html string with 500 p tag with timestamp in it

i use UIWebView and WKWebView loadHTMLString:baseURL: to load it,and wkWeb

4条回答
  •  误落风尘
    2020-12-11 23:44

    For me, creating static variable to avoid creating WKWebView multiple times worked. Objective-C example:

    - (WKWebView *)webHeaderView
    {
        static WKWebView *_webHeaderView = nil;
        static dispatch_once_t onceToken;
    
        dispatch_once(&onceToken, ^{
            if (!_webHeaderView)
            {
                WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
                _webHeaderView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
            }
        });
    
        return _webHeaderView;
    }
    

提交回复
热议问题