zoukankan      html  css  js  c++  java
  • cordova 导致css中绝对定位top:0会被顶到视图之外

    • IOS7+ webview全屏导致状态栏悬浮在页面上
      解决方案:打开 ios项目/classes/MainViewController.m,修改viewWillAppear方法
    - (void)viewWillAppear:(BOOL)animated  
    {  
        // View defaults to full size.  If you want to customize the view's size, or its subviews (e.g. webView),  
        // you can do so here.  
        if([[[UIDevice currentDevice]systemVersion ] floatValue]>=7)  
        {  
            CGRect viewBounds=[self.webView  bounds];  
            viewBounds.origin.y=20;  
            viewBounds.size.height=viewBounds.size.height-20;  
            self.webView.frame=viewBounds;  
        }  
      
        [super viewWillAppear:animated];  
    } 
    

    PS:更新cordova-plugin-statusbar插件为2.2.3之后,好像失效了
    暂时把配置项改成这样

      <preference name="StatusBarStyle" value="defaults" />
    
    • ios聚焦打开键盘时,webview没有收缩高度,导致css中绝对定位top:0会被顶到视图之外
      解决方案:添加cordova-plugin-keyboard插件,然后js调用插件的方法,使开启键盘时收缩webview
    // 安装cordova-plugin-keyboard
    cordova plugin add cordova-plugin-keyboard
    

    然后在deviceready事件中调用全局Keyboard.shrinkView方法

    document.addEventListener('deviceready', () => {
      window.Keyboard.shrinkView(true);
      // 其他代码
      ...............
    }
    
    • ios自动聚焦无效(例如 autofocus、jq的$(xxx).focus())
      解决方案:在cordova配置文件config.xml中增加以下配置:
    <preference name="KeyboardDisplayRequiresUserAction" value="false" />
    

    持续更新,暂时 只碰到 || 只想起 这几个



    作者:kamifun
    链接:https://www.jianshu.com/p/bf4b0a5d459a
    來源:简书
    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
  • 相关阅读:
    Linux 文件取交集 并集 差集
    阿里花名推荐
    Linux bg fg命令的使用
    python导入自己创建的本地包报错
    数值计算方法
    数据库oracle回顾
    使用visualBox创建Centos/7,搭建docker,安装mysql,及远程连接
    git 合并分支到master
    git 本地文件修改错误,重新取回服务器历史版本
    三本不错的计算机专业书籍(需求分析,开发实务,恶意代码分析)
  • 原文地址:https://www.cnblogs.com/zzsdream/p/10041953.html
Copyright © 2011-2022 走看看