钛合金 ipad 条形图像随方向变化
我有两个标题图像,宽度分别为 768 和 1024,分别用于纵向和横向。但有时(当导航到上一个视图时)方向改变时图像不会改变。我使用以下代码:
Ti.UI.orientation = Titanium.Gesture.orientation;
Titanium.Gesture.addEventListener('orientationchange', function(e) {
w.barImage = 'null';
//alert("Orientation Change"+o);
var o = Titanium.Gesture.orientation;
if(o==1||o==2)
{
w.barImage='barImage768.png';
w.add(navBar);
}
else if(o==4||o==3)
{
w.barImage='barImage.png';
w.add(navBar);
}
});
任何人都有解决方案。有时我会在警报中得到 0 方向。
I have two title images of 768 and 1024 width for portrait and landscape orientation. But sometimes (when navigate to previous view) the images not make change when orientation change.I am using following code:
Ti.UI.orientation = Titanium.Gesture.orientation;
Titanium.Gesture.addEventListener('orientationchange', function(e) {
w.barImage = 'null';
//alert("Orientation Change"+o);
var o = Titanium.Gesture.orientation;
if(o==1||o==2)
{
w.barImage='barImage768.png';
w.add(navBar);
}
else if(o==4||o==3)
{
w.barImage='barImage.png';
w.add(navBar);
}
});
Anybody have solution for that. Sometimes I get 0 orientation in alert.
当设备朝上或朝下时,可能会获得未知方向值 0 和 5 或 6。
它帮助我们跟踪最后一个“真实”方向值(值 1、2、3 或 4),并在收到值 0、5 或 6 时继续使用该值。
It is possible to get orientation values of 0 for unknown and 5 or 6 when the device is facing up or down.
It worked for us to keep track of the last "real" orientation value (values of 1, 2, 3, or 4) and continue to use that when a value of 0, 5, or 6 is received.