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

  • 相关阅读:
    DOM getElementById
    百度之星2014
    游艇租借
    2014年acm亚洲区域赛·鞍山站
    UVALive 4255 Guess
    UVA 10054 The Necklace
    UVA 10047 The Monocycle
    UVA 11624 Fire!
    第九届黑龙江省赛
    剑指offer系列31-----二叉树的下一个节点
  • 原文地址:https://www.cnblogs.com/zsychanpin/p/7041339.html
Copyright © 2011-2022 走看看