I'm currently using Appcelerator studio v4.5.0 and Ti SDK 5.2.2. This question concerns both iOS and Android since the behaviour appears to be the same.
I want to insert data at the top of a table. When I insert the data, I want the table to remain static aka Twitter. The data should appear above what the user is currently viewing with no jumping or moving of the table other than by the user. With all the methods I have tried what you were looking at gets pushed down by the number of rows added. If you add enough rows - the experience is jarring.
I have tried the following and all result in the table moving:
- keeping the source array around, inserting to that and "refreshing" the entire data in the table (This old post - Disable autoscroll top on insertRowBefore in a TableView in Appcelerator/Titanium)
- using table.insertRowBefore(index, row) and table.isertRowAfter(index, row)
- adding the row(s) to a new section and using table.insertSectionBefore(index, section) and table.insertSectionAfter(index, section)
- set table.scrollable to false (just to give it a go)
I am currently in the process of trying to use a mixture of knowing the row heights/number of rows and using table.scrollToIndex() or table.scrollToTop(). But so far both of these result in a very jumpy experience especially if the user is currently scrolling. On Android both of these functions take a finite position and half rows are not available.
Is there a setting that I am missing that forces the table to do this? Or is it pure indexing and what used to be index 5 in the table is now index 7 (after adding 2 rows) and the table stays at index 5? I would really hate to have to "design around this" since it is obviously possible.
Any help appreciated.