[英]Handling Orientation Change for iOS in Titanium Studio?
我已經閱讀了文檔並擁有以下代碼,但顯然缺少一些東西。
Ti.Gesture.addEventListener('orientationchange', function (ev) {
if (Ti.Gesture.isLandscape(ev.orientation)) {
// Update your UI for landscape orientation
} else {
// Update your UI for portrait orientation
}
});
如上面的評論中所述,我應該怎么做來更新我的UI? 我有一個簡單的TabGroup,其中包含WebViews。 我想念什么?
如果要在窗口中更改Orentaion
用這個
var window = Ti.UI.createWindow({
orientationModes: [
Ti.UI.LANDSCAPE_LEFT,
Ti.UI.LANDSCAPE_RIGHT,
Ti.UI.PORTRAIT,
Ti.UI.UPSIDE_PORTRAIT
]
});
此代碼告訴您,您的窗口現在具有所有原點了
現在您需要對UI進行一些更改,例如在portaint中,您的寬度為:320,高度為480
您需要知道更改的時間。 soo oreintchange事件被使用
Ti.Gesture.addEventListener('orientationchange', function(e) {
Titanium.API.info('Orientation changed to '+e.orientation);
if(e.orientaion=="Ti.UI.PORTRAIT")
{
width:320,height:480
}
else{
width:480,height:320
}
});
看這個例子。這會有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.