How do you link to pages/windows in Titanium Mobile without tabs?

允我心安 提交于 2020-01-13 06:56:23

问题


I realize this is the most basic of questions, but I am unable to find out how to link between windows without using tabs.

The following code works to close a window, which sort of works as a back button. But how do I specify which file/url I would like to link to?

btn_home.addEventListener("click", function() {
Ti.UI.currentWindow.close();
});

I found a solution:

btn_home.addEventListener('click', function() { 
var newWindow = Titanium.UI.createWindow({ url: 'home.js' }); 
newWindow.open(newWindow,{animated:true}); 
});

回答1:


There is a few ways you can do this.

App flow for samples:

  1. app.js opens page1.js
  2. page1.js opens page2.js ( just like the code you have above )

Approaches:

  1. Add a button to the navbar, toolbar or customized view that acts like a "back" button and closes page2.js
  2. Create a window manager through events. This usually sits in the app.js and manages what windows are opened and closed.
  3. Use TabGroups, but hide the TabBar when the window is open by setting tabBarHidden:true. You'll have to do this when opening all windows though.

If you're only building on iOS I'd recommend #3 as it is easiest. If you are also doing Android #2 would provide the greatest amount of flexibility as it allows you to better style the page "header".



来源:https://stackoverflow.com/questions/5766614/how-do-you-link-to-pages-windows-in-titanium-mobile-without-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!