在Appcelerator/Titanium中的TableView中,在insertRowBefore上禁用自动滚动顶部 [英] Disable autoscroll top on insertRowBefore in a TableView in Appcelerator/Titanium
问题描述
我目前正在使用TableView在Appcelerator/Titanium中显示某些元素. 我的问题是,当我拉动刷新并调用方法" insertRowBefore "时,会使用如下方法在表的开头插入新元素:
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?
推荐答案
我遇到了同样的问题,即在表的顶部插入行时看起来非常难看.我通过不直接在表中插入行,而是先将它们插入到数组中来管理这种奇怪的行为:
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]);
然后设置表格的数据
$.table.setData(oldRows);
这篇关于在Appcelerator/Titanium中的TableView中,在insertRowBefore上禁用自动滚动顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!