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)