Titanium 单击按钮创建新窗口时UI冻结
我是钛合金新手,我面临一个问题。 在我的app.js中,我在窗口中包括一个左菜单和控件(app.js和leftmenu.js) 我想在用户单击菜单项时加载一个窗口。基本上,我想在用户选择主页按钮时加载app.js主窗口。 为此,我在leftmenu.js文件中添加了以下代码:Titanium 单击按钮创建新窗口时UI冻结,titanium,appcelerator,Titanium,Appcelerator,我是钛合金新手,我面临一个问题。 在我的app.js中,我在窗口中包括一个左菜单和控件(app.js和leftmenu.js) 我想在用户单击菜单项时加载一个窗口。基本上,我想在用户选择主页按钮时加载app.js主窗口。 为此,我在leftmenu.js文件中添加了以下代码: var newWin = Titanium.UI.createWindow({ url: "app.js", zIndex: 0 }); win.close(); // closing main windo
var newWin = Titanium.UI.createWindow({
url: "app.js",
zIndex: 0
});
win.close(); // closing main window
leftMenu.close(); // closing left menu
newWin.open(); //should reload the main window and the leftmenu
它将重新加载窗口,但所有控件都处于禁用状态。我们不能点击任何控件。这就像所有控件都在一个不可见的层下一样。
有什么想法吗
我复制/粘贴代码部分,也许会更清楚:)
您好,我知道一个月后,但您是否使用require和exports/module.exports?下面是一个关于如何正确使用按钮事件打开新窗口的示例,我认为使用url属性是不可取的,所以我希望这个示例可以帮助您理解 employee.js
//Current window (employee window)
var employeeWin = Ti.UI.currentWindow;
//define button
var moveToDetailBtn = Ti.UI.createButton({
width : 200, //define the width of button
height : 50, //define height of the button
title : 'Show Detail' //Define the text on button
});
//Click event to open the Employee Details window
moveToDetailBtn.addEventListener('click', function(){
//Call a export function
var win = require('employeeDetails').getEmployeeDetailSWin;
//Create new instance
var employeeDetailsWin = new win();
//Open the Employee Details window
employeeDetailsWin.open();
});
//Add the button to the window
employeeWin.add(moveToDetailBtn);
exports.getEmployeeDetailSWin = function(){
//Creates a new window
var empDetailsWin = Ti.UI.createWindow({
backgroundColor : '#ffffff' //Define the backgroundcolor of the window
});
//Addin a label to the window
empDetailsWin.add(Ti.UI.createLabel({
width : 100, //Define width of the label
height : 50, //Define height of the label
title : 'Employee Details'
}));
return empDetailsWin;
};
在employeeDetails.js中
//Current window (employee window)
var employeeWin = Ti.UI.currentWindow;
//define button
var moveToDetailBtn = Ti.UI.createButton({
width : 200, //define the width of button
height : 50, //define height of the button
title : 'Show Detail' //Define the text on button
});
//Click event to open the Employee Details window
moveToDetailBtn.addEventListener('click', function(){
//Call a export function
var win = require('employeeDetails').getEmployeeDetailSWin;
//Create new instance
var employeeDetailsWin = new win();
//Open the Employee Details window
employeeDetailsWin.open();
});
//Add the button to the window
employeeWin.add(moveToDetailBtn);
exports.getEmployeeDetailSWin = function(){
//Creates a new window
var empDetailsWin = Ti.UI.createWindow({
backgroundColor : '#ffffff' //Define the backgroundcolor of the window
});
//Addin a label to the window
empDetailsWin.add(Ti.UI.createLabel({
width : 100, //Define width of the label
height : 50, //Define height of the label
title : 'Employee Details'
}));
return empDetailsWin;
};
此外,我不确定你是否可以导出你的app.js尝试使用新的.js