Hi, I'm trying to reload tableview but it crash after setData([]) (I want clear the tableview to re-populate)
First win focus it's works... from second no... it crash and report: Assertion failure in -[_UITableViewUpdateSupport _computeRowUpdates], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableViewSupport.m:386
If my code is wrong, what's the right method to reload data of tableview ?
tableview2 = Ti.UI.createTableView({ backgroundColor: 'transparent', style: Ti.UI.iPhone.TableViewStyle.PLAIN, separatorStyle: Titanium.UI.iPhone.TableViewSeparatorStyle.NONE, top: 2 }); win.addEventListener('focus', function(){ tableview2.setData([]); win.add(function_A()); win.add(function_B()); win.add(function_C()); }) function function_A(){ var img1 = Ti.UI.createImageView({ image: '../images/aaa.png', top: 8, left: 10 }); var img2 = Ti.UI.createImageView({ image: '../images/bbb.png', top: 8, left: 120 }); var r = Ti.UI.createTableViewRow({ hasDetail:false, borderColor: 'transparent' }); r.add(img1); r.add(img2); tableview2.appendRow(r); return tableview2; } function function_B(){ ..... return tableview2; } function function_C(){ ..... return tableview2; }Thank you for help.
Best regard
2 Answers
Accepted Answer
I had the same error. Every time I reloaded the table, I got this error. My solution was to manage the table data array by my own array. This error was since Titanium SDK 2.0.2.
Previews method of reloading a Table:
mytable.setData([]); mytable.appendRow(createRow()); mytable.appendRow(createRow()); ...Current reloading
var tableData = []; tableData.push(createRow()); tableData.push(createRow()); mytable.setData(tableData);Now it works.
Yes, I use the same method now. :)
Your Answer
Think you can help? Login to answer this question!