问题
i'm currently using a TableView to display some elements in Appcelerator/Titanium. The problem that i have is that when i make a pull to refresh and i call the method "insertRowBefore" to insert new elements at the beginning of the table using the method like following:
$.table.insertRowBefore(0,row);
The table auto scrolls to top, and it looks a little bit bad when there're a lot rows to insert, i want to keep the current position. Any ideas?
回答1:
I have had the same problem it looks very ugly when inserting rows at table's top. I have managed this strange behavior by not inserting rows in table directly but inserting them to an array first :
//i suppose that you have an initial array contain your old rows oldRows
//add rows in the top
for(int i=0;i<7;i++)
oldRows.unshift(newRows[i]);
then set table's data
$.table.setData(oldRows);
来源:https://stackoverflow.com/questions/24500321/disable-autoscroll-top-on-insertrowbefore-in-a-tableview-in-appcelerator-titaniu