我正在重新访问一个使用 Classic(不是 Alloy)创建的旧应用程序,需要删除已弃用的 window:url 功能,但在这个新更新中,我需要在 tabGroup 中添加一些导航窗口。
我知道我需要创建一个我可以调用的全局变量,这样我就可以在正确的选项卡中打开新窗口。
谁能指出我正确的方向?
所以我真的有两个问题。
- 导入另一个 JS 文件(在 Classic 中)以替换窗口 URL 方法的最佳方法是什么?
和
- 如何设置全局设置(同样是在 Classic 中)以便我可以在我的 tabGroup 中打开和关闭窗口?
这是我在 tabs.js 中的选项卡设置(窗口中有我其他 JS 文件的 URL)
// create tab group
var tabGroup = Ti.UI.createTabGroup({
tintColor: '#FFF',
barColor: '#ff5700',
tabsTintColor:'#333333',
navTintColor: '#FFF',
tabsBackgroundColor :'#ff5700'
});
// Assign windows & tabs
var win1 = Titanium.UI.createWindow({ backgroundColor:'#fff', barColor:'#ff5700', url:'team.js', title:'Team', navTintColor:'#FFF', titleAttributes:{color: '#FFF'}});
var tab1 = Titanium.UI.createTab({ window:win1, icon:'images/team.png', title:'Team', titleColor:'#FFF', activeTitleColor:'#333', activeIcon:'images/team.png', activeIconIsMask:true, iconIsMask:false});
var win2 = Titanium.UI.createWindow({ backgroundColor:'#fff', barColor:'#ff5700', url:'league.js', title:'League', navTintColor:'#FFF', titleAttributes:{color: '#FFF'}});
var tab2 = Titanium.UI.createTab({ window:win2, icon:'images/league.png', title:'League', titleColor:'#FFF', activeTitleColor:'#333', activeIcon:'images/league.png', activeIconIsMask:true, iconIsMask:false});
var win3 = Titanium.UI.createWindow({ backgroundColor:'#fff', barColor:'#ff5700', url:'fixtures.js', title:'Fixtures', navTintColor:'#FFF', titleAttributes:{color: '#FFF'}});
var tab3 = Titanium.UI.createTab({ window:win3, icon:'images/fixtures.png', title:'Fixtures', titleColor:'#FFF', activeTitleColor:'#333', activeIcon:'images/fixtures.png', activeIconIsMask:true, iconIsMask:false});
var win4 = Titanium.UI.createWindow({ backgroundColor:'#fff', barColor:'#ff5700', url:'players.js', title:'Players', navTintColor:'#FFF', titleAttributes:{color: '#FFF'}});
var tab4 = Titanium.UI.createTab({ window:win4, icon:'images/players.png', title:'Players', titleColor:'#FFF', activeTitleColor:'#333', activeIcon:'images/players.png', activeIconIsMask:true, iconIsMask:false});
var win5 = Titanium.UI.createWindow({ backgroundColor:'#fff', barColor:'#ff5700', url:'more.js', title:'More', navTintColor:'#FFF', titleAttributes:{color: '#FFF'}});
var tab5 = Titanium.UI.createTab({ window:win5, icon:'images/more.png', title:'More', titleColor:'#FFF', activeTitleColor:'#333', activeIcon:'images/more.png', activeIconIsMask:true, iconIsMask:false});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.addTab(tab3);
tabGroup.addTab(tab4);
tabGroup.addTab(tab5);
tabGroup.open();
这是我想在我的一个选项卡中的另一个窗口中调用的方式。我已经从中删除了大量代码,因为您不需要查看所有代码!
var createWin = Titanium.UI.createWindow({
backgroundColor: 'blue',
title: 'Create League'
});
createButton.addEventListener('click', function(){
tabGroup.activeTab.open(createWin);
});
我需要以某种方式让 tabGroup.activeTab.open(createWin); 进入作用域!
如有任何帮助,我们将不胜感激!
西蒙
最佳答案
您可以使用 Ti.App.tabGroup
使其成为全局的,然后使用 Ti.App.tabGroup.activeTab.open(createWin);
关于javascript - 使用 Appcelerator 在 iOS 上的 TabGroup 中打开 Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34902176/