Cordova+vue项目打包ios运行上下滑动出现空白解决方法(webview)

Cordova+vue项目打包ios运行上下滑动出现空白解决方法(webview)
这是cordova项目打包ios后出现页面往上滑,或者往下滑的时候,一旦滚到边界的时候,在接着滚到的时候便会出现白块,查了很多资料,最后解决了,把方法分享出来!
先上图
Cordova+vue项目打包ios运行上下滑动出现空白解决方法(webview)

这是cordova+vue的项目结构

Cordova+vue项目打包ios运行上下滑动出现空白解决方法(webview)

修改图中标注的文件,具体的意思图中标出,
代码片段一

  1.  
    CGFloat webViewHeight=[webView.scrollView contentSize].height;
  2.  
    CGRect newFrame = webView.frame;
  3.  
    newFrame.size.height = webViewHeight;
  4.  
    webView.frame = newFrame;

代码片段二

[(UIScrollView *)[[webView subviews] objectAtIndex:0] setBounces:NO];


上面是cordova ios 5.x的代码 如果是用的 cordova ios版本 6.x 使用的是wkwebview 是没有 webviewdidfinishload方法的

cordovaLib => Classes => Private => Plugins => CDVWebViewEngine.m 文件 didFinishNavigation方法

- (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation
{
    CGFloat webViewHeight = [webView.scrollView contentSize].height;
    CGRect newFrame = webView.frame;
    newFrame.size.height = webViewHeight;
    webView.frame = newFrame;
    
    [(UIScrollView *)[[webView subviews] objectAtIndex:0] setBounces:NO];
    
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:webView]];
}