zoukankan      html  css  js  c++  java
  • Cordova+vue项目打包ios运行上下滑动出现空白解决方法(webview)

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

    这是cordova+vue的项目结构

    图片描述

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

    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]];
    }
  • 相关阅读:
    日志处理
    md5加密
    os 模块
    time模块
    函数的进阶
    参数 返回值
    文件操作
    集合 拷贝
    linux如何更快的远程拷贝?scp,tar,rsync?
    修改内核临时端口范围
  • 原文地址:https://www.cnblogs.com/xtxtx/p/14487001.html
Copyright © 2011-2022 走看看