我在日志和错误的导航组中收到以下消息
2011-10-27 21:41:21.575 bugtitanium[15903:207] nested push animation can result in corrupted navigation bar
2011-10-27 21:41:21.945 bugtitanium[15903:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2011-10-27 21:41:21.946 bugtitanium[15903:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
附加代码重现;在第一次加载时,一切正常,点击一次重新加载,单击一行并单击后退按钮
做同样的并重新加载2次,你将不得不按下后退按钮2次,依此类推......
有人可以给我一个解决方法或修复吗?
我需要将表加载并填充为异步进程
代码是
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var mytasks_helping_button = Ti.UI.createButton({
title : 'Reload',
top:0,
color:'black',
width:200,
height:30,
style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
win1.add(mytasks_helping_button);
var mytasks_helping_tableview = Titanium.UI.createTableView({
top:100
});
win1.add(mytasks_helping_tableview);
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
function populateData(datasourcetmp,tabletmp){
var data = [];
for( i = 0; i < datasourcetmp.length; i++) {
var row = Titanium.UI.createTableViewRow({
height : 120,
backgroundColor:'#fff',
borderWidth : 0,
borderColor : 'transparent'
});
var my_tasks_table_top_label = Titanium.UI.createLabel({
text : 'test row:'+i+' date:'+new Date(),
width : "100%",
font : {
fontSize : 12,
fontFamily : 'Helvetica'
},
color : "black",
top : 30,
height : 20,
left : 5
});
row.add(my_tasks_table_top_label);
data.push(row);
};
mytasks_helping_tableview.addEventListener('click', function(e) {
//view a task screen
var viewTask = Titanium.UI.createWindow({
height : "100%",
width : "100%",
title : "Helping with",
barColor : 'lightGray'
});
var viewTask_top_label = Titanium.UI.createLabel({
text : 'nested view '+ e.index,
width : "80%",
font : {
fontSize : 15,
fontFamily : 'Helvetica'
},
color : "gray",
top : 10,
height : 20,
left : 60
});
viewTask.add(viewTask_top_label);
tab1.open(viewTask);
});
tabletmp.setData(data);
}
var datasource = ['1','2','3','4','5','6','7'];
populateData(datasource,mytasks_helping_tableview);
mytasks_helping_button.addEventListener('click', function(e) {
populateData(datasource,mytasks_helping_tableview);
});
tabGroup.addTab(tab1);
tabGroup.open();
答案 0 :(得分:0)
在上面的代码中,每次调用populateData时都要添加一个事件监听器。
mytasks_helping_tableview.addEventListener('click', function....
添加事件侦听器不会“替换”现有的事件侦听器,因此它会在第一次“加载”并打开多个窗口后多次触发。
将mytasks_helping_tableview.addEventListener调用移到populateData函数外部。
答案 1 :(得分:0)
实际上,一种更灵活的修复方法是通过不同的表comp使用代码来创建表实例的映射,并且每次都删除前一个实例并重建
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var mytasks_helping_button = Ti.UI.createButton({
title : 'Reload',
top:0,
color:'black',
width:200,
height:30,
style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
win1.add(mytasks_helping_button);
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var tableView={};
function populateData(datasourcetmp,tableName){
if(tableView[tableName]){
win1.remove(tableView[tableName]);
delete tableView[tableName];
}
var tabletmp = Titanium.UI.createTableView({
top:100
});
win1.add(tabletmp);
tableView[tableName] = tabletmp;
var data = [];
for( i = 0; i < datasourcetmp.length; i++) {
var row = Titanium.UI.createTableViewRow({
height : 120,
backgroundColor:'#fff',
borderWidth : 0,
borderColor : 'transparent'
});
var my_tasks_table_top_label = Titanium.UI.createLabel({
text : 'test row:'+datasourcetmp[i]+' date:'+new Date(),
width : "100%",
font : {
fontSize : 12,
fontFamily : 'Helvetica'
},
color : "black",
top : 30,
height : 20,
left : 5
});
row.add(my_tasks_table_top_label);
data.push(row);
};
tabletmp.addEventListener('click', function(e) {
//view a task screen
var viewTask = Titanium.UI.createWindow({
height : "100%",
width : "100%",
title : "Helping with",
barColor : 'lightGray'
});
var viewTask_top_label = Titanium.UI.createLabel({
text : 'nested view '+ e.index,
width : "80%",
font : {
fontSize : 15,
fontFamily : 'Helvetica'
},
color : "gray",
top : 10,
height : 20,
left : 60
});
viewTask.add(viewTask_top_label);
tab1.open(viewTask);
});
tabletmp.setData(data);
}
var datasource = ['1','2','3'];
populateData(datasource,'mytasks');
mytasks_helping_button.addEventListener('click', function(e) {
datasource = ['4','5','6','7'];
populateData(datasource,'mytasks');
});
tabGroup.addTab(tab1);
// open tab group
tabGroup.open();