zoukankan      html  css  js  c++  java
  • [Phonegap+Sencha Touch] 移动开发26 Android下的sencha touch程序,转屏时,Ext.Viewport不能触发orientationchange事件的解决的方法

    Sencha touch 2.4.2 已经解决问题了。


    比方你为Ext.Viewport的orientationchange事件加入了一个监听方法:

    Ext.Viewport.on('orientationchange', function(){  alert('转屏了')  }, this);


    经測试,安卓自带浏览器,或者phonegap打包的app。在转屏的时候都没有弹出"转屏了"的对话框。(sencha官方论坛有非常多人反映这个问题,貌似sencha touch 2.0+都存在)

    而chrome for android打开这个webapp,尽管能触发。可是第一次转屏没有触发,第二次转屏触发运行的是第一次的监听方法。



    解决的方法:

    在app.js的launch方法中,加入以下的代码:

    <span style="font-family:Microsoft YaHei;">if (Ext.os.is.Android) {
        Ext.Viewport.addWindowListener('resize', Ext.Function.bind(Ext.Viewport.onResize, Ext.Viewport));
    
        Ext.Viewport.updateSize(); //added
        Ext.Viewport.orientation = Ext.Viewport.determineOrientation(); //added
    }</span>




    欢迎增加Sencha Touch + Phonegap 群:194182999

    共同学习交流(博主QQ:479858761

  • 相关阅读:
    Redis之数据类型大全
    基于服务的SOA架构
    mybatis_个人总结
    mybatis_开发篇
    mybatis_基础篇
    mybatis_常用标签
    mybatis_映射查询
    solr_架构案例【京东站内搜索】(附程序源代码)
    Solr_全文检索引擎系统
    zabbix监控搭建步骤
  • 原文地址:https://www.cnblogs.com/zsychanpin/p/7041339.html
Copyright © 2011-2022 走看看