使用如下方式創建WKWebView來加載H5頁面內容:
WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - KNavHeight)];
webView.UIDelegate = self;
webView.navigationDelegate = self;
webView.scrollView.delegate = self;
在頁面底部有個懸浮分享面板,所以使用了webView.scrollView.delegate = self,通過滾動來顯示或者隱藏分享面板。
H5加載完成后回退頁面,有如下錯誤報出:
*** -[XxxViewController retain]: message sent to deallocated instance xxx。
去掉webView.scrollView.delegate = self問題解決。