Javascript 使用Appcelerator在iOS上打开选项卡组内的窗口
我正在访问一个使用Classic(非Alloy)创建的旧应用程序,需要删除不推荐的window:url功能,但在这个新的更新中,我需要在选项卡组中添加一些导航窗口 我知道我需要创建一个可以调用的全局窗口,以便在正确的选项卡中打开新窗口 谁能给我指出正确的方向吗 所以我有两个问题Javascript 使用Appcelerator在iOS上打开选项卡组内的窗口,javascript,ios,titanium,appcelerator,Javascript,Ios,Titanium,Appcelerator,我正在访问一个使用Classic(非Alloy)创建的旧应用程序,需要删除不推荐的window:url功能,但在这个新的更新中,我需要在选项卡组中添加一些导航窗口 我知道我需要创建一个可以调用的全局窗口,以便在正确的选项卡中打开新窗口 谁能给我指出正确的方向吗 所以我有两个问题 导入另一个JS文件(在经典中)以替换窗口URL方法的最佳方法是什么 及 如何设置全局设置(同样是经典设置),以便在选项卡组中打开和关闭窗口 这是我在tabs.js中的选项卡设置(窗口中其他js文件的URL) 下面是我想在
var createWin = Titanium.UI.createWindow({
backgroundColor: 'blue',
title: 'Create League'
});
createButton.addEventListener('click', function(){
tabGroup.activeTab.open(createWin);
});
我需要获得tabGroup.activeTab.open(createWin)以某种方式进入范围
任何帮助都将不胜感激
Simon您可以使用
Ti.App.tabGroup
和Ti.App.tabGroup.activeTab.open(createWin)使其成为全局的
您可以使用Ti.App.tabGroup
使其成为全局的,然后使用Ti.App.tabGroup.activeTab.open(createWin)代码>首先,您的windows可以作为CommonJS模块位于另一个文件中。
大概是这样的:
//tabTeam.js file
function tabTeam(){
var win = Ti.UI.createWindow({
backgroundColor:'yellow'
});
//put the code of your window here as usually
//don't forget to return the window
return win;
}
module.exports = tabTeam;
var teamWindow = require("tabTeam")();
然后,对于tabgroup,正如Sebastian所说,您应该使用Ti.App全局属性,比如:
Ti.App.tabgroup = Ti.UI.createTabGroup({}
backgroundColor:'white'
);
要想打开窗户,请执行以下操作:
//tabTeam.js file
function tabTeam(){
var win = Ti.UI.createWindow({
backgroundColor:'yellow'
});
//put the code of your window here as usually
//don't forget to return the window
return win;
}
module.exports = tabTeam;
var teamWindow = require("tabTeam")();
并将其添加到选项卡组:
var tab1 = Ti.UI.createTab({
icon:'asdasd.png',
window:teamWindow
});
并使用tabgroup.open()打开tabgroup
如果您在一个窗口内,并且希望在同一选项卡中打开另一个窗口,并使用很酷的iOS导航动画,请执行以下操作:
btOpenWindow.addEventListener('click',function(){
var profileWindow = require("profile")(parameters);
Ti.App.tabgroup.activeTab.open(profileWindow);
});
就这些!如果works=)请告诉我,首先,您的windows可以作为CommonJS模块保存在另一个文件中。
大概是这样的:
//tabTeam.js file
function tabTeam(){
var win = Ti.UI.createWindow({
backgroundColor:'yellow'
});
//put the code of your window here as usually
//don't forget to return the window
return win;
}
module.exports = tabTeam;
var teamWindow = require("tabTeam")();
然后,对于tabgroup,正如Sebastian所说,您应该使用Ti.App全局属性,比如:
Ti.App.tabgroup = Ti.UI.createTabGroup({}
backgroundColor:'white'
);
要想打开窗户,请执行以下操作:
//tabTeam.js file
function tabTeam(){
var win = Ti.UI.createWindow({
backgroundColor:'yellow'
});
//put the code of your window here as usually
//don't forget to return the window
return win;
}
module.exports = tabTeam;
var teamWindow = require("tabTeam")();
并将其添加到选项卡组:
var tab1 = Ti.UI.createTab({
icon:'asdasd.png',
window:teamWindow
});
并使用tabgroup.open()打开tabgroup
如果您在一个窗口内,并且希望在同一选项卡中打开另一个窗口,并使用很酷的iOS导航动画,请执行以下操作:
btOpenWindow.addEventListener('click',function(){
var profileWindow = require("profile")(parameters);
Ti.App.tabgroup.activeTab.open(profileWindow);
});
就这些!如果works=)在app.js中创建全局变量,请告诉我
var tabGroupGlobal;
在当前窗口中,创建tabgroup并将其分配到全局变量中
var tabGroup = Ti.UI.createTabGroup({
tintColor: '#FFF',
barColor: '#ff5700',
tabsTintColor:'#333333',
navTintColor: '#FFF',
tabsBackgroundColor :'#ff5700'
});
tabGroupGlobal = tabGroup;
现在,您可以在任何窗口中使用tabGroupGlobal
btOpenWindow.addEventListener('click',function(){
var newWindow = Ti.UI.createWindow({});
tabGroupGlobal.activeTab.open(newWindow);
});
我想这可能对你有帮助。如果有任何错误或建议,请告诉我。在app.js中创建全局变量
var tabGroupGlobal;
在当前窗口中,创建tabgroup并将其分配到全局变量中
var tabGroup = Ti.UI.createTabGroup({
tintColor: '#FFF',
barColor: '#ff5700',
tabsTintColor:'#333333',
navTintColor: '#FFF',
tabsBackgroundColor :'#ff5700'
});
tabGroupGlobal = tabGroup;
现在,您可以在任何窗口中使用tabGroupGlobal
btOpenWindow.addEventListener('click',function(){
var newWindow = Ti.UI.createWindow({});
tabGroupGlobal.activeTab.open(newWindow);
});
我想这可能对你有帮助。如果有任何错误或建议,请告诉我。太好了!我要试一试,谢谢你的回答:)太好了!我要试一试,谢谢你的回答:)