在 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屋!