2013-09-25 37 views
-3

我在編程世界很新。我使用Titanium,我想要一個按鈕,當我點擊它時,它會回到主窗口。顯然,該按鈕將位於另一個窗口中。我想試試win2.open()win2.show(),但它不工作。有任何想法嗎?如何創建主頁按鈕?

+3

什麼是'win2'?你能告訴我們更多的代碼嗎? – Raptor

回答

0

的Jacl,

如果你在第二個窗口,只需關閉該窗口上的按鈕的單擊事件在第二個窗口。 嘗試在第二窗口

//I'm assuming that you have came from window1 to window2 
//and you have a button btnHome at window 2 used to navigate back to home page 

var thisWindow = Ti.UI.currentWindow; 
btnHome.addEventListener('click', function(e){ 
    thisWindow.close(); //Will close the current window and display the previous one 
}); 

存在被使用的窗口之間進行導航類似的問題如下。通過Titanium Mobile: cant navigate between pages

您可以使用下面的鏈接也引用

  1. http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-url
  2. http://docs.appcelerator.com/titanium/latest/#!/api/Global-method-require
+0

沒有工作。它說不能調用方法關閉null – Jack

+0

但謝謝你的回答。也許這是一個背景問題你認爲? – Jack

+0

你是怎麼打開窗戶的?你能顯示代碼嗎? – Anand