2011-10-14 54 views
1

我想我可能會將太多正常的上下文(web app dev)應用到使用Titanium的新移動項目中。我有一個包含幾個按鈕的主屏幕。我需要每個按鈕以全新的內容打開一個新窗口。在我的腦海中,我只是假設窗戶可以像請求或頁面一樣工作,創建並打開一個新窗口將完全用新的窗口取代現有的內容。這似乎並不是這種情況(或者我正在做可怕的事情,可怕的錯誤)。在我的主頁屏幕上,下面是一個按鈕的事件處理程序:Hyperlink Equivalent

btn_er_app.addEventListener('click', function(e) { 
    var win = Ti.UI.createWindow({ 
     bottom: 0, 
     title: 'Next "Page"', 
     top: 0, 
     url: 'next_page.js', 
    }); 
    win.open({ animated: true }); 
}); 

next_page.js頁面看起來像這樣(片段):

var win = Ti.UI.currentWindow; 
win.layout = 'vertical'; 

var header = Ti.UI.createView({ 
    backgroundColor: '#f00', 
    height: 60, 
    top: 0, 
}); 
win.add(header); 

var body = Ti.UI.createView({ 
    backgroundColor:'#000', 
    backgroundImage: '/images/body.png', 
}); 
var label = Ti.UI.createLabel({ 
    text: 'Page Bits Go Here', 
    textAlign: 'center', 
}); 
body.add(label); 

win.add(body); 

什麼我的發現是,在主屏幕上的內容仍然是可見。紅色標題塊顯示,但不是身體視圖。我試過設置屬性:height: '100%',bottom: 0,height: 'auto'甚至將新窗口的fullscreen值設置爲true,但沒有任何效果。

首先,「鏈接」如何在移動空間中工作?我真的認爲我的整個思考過程需要重新整理,其次,我需要做些什麼來使我的新窗口完全掩蓋底層主屏幕窗口?

感謝您的幫助。

回答

1

您不應該更換窗口,而是實際創建一個新窗口,並讓它打開。

根據你想達到的目標,你應該創建一個模態窗口。

方法如下:您可以

var newWin = Ti.UI.createWindow({ 
    modal: true, 
    title: 'new Window', 
    navBarHidden: false 
}); 

// adding a button to close the window again: 

var button = Ti.UI.createButton({ 
    title: 'Close' 
}); 

button.addEventListener('click',function(){ 
    newWin.close(); 
    newWin.hide(); 
}); 

win.leftNavButton = button; 

newWin.open(); 

在這個窗口做這樣的事情,並添加你的意見等