How to scroll the table view to bottom in Livequery by using CBLTableSource in IOS?



Hi all, I’m using CBL lite 1.3 in my iOS app. In my application I am displaying the table of content from old docs to new docs i.e old docs on top and new docs on bottom. I have given CBLTableSource to my table view datasource and applying live query on the same datasource.Here my problem is if any change happened in database the table view scrolls to top by default. But my requirement is whenever the change happened in database the table view must scroll to bottom by default because my latest data is at bottom of the table. How can I achieve this?

Initially in CBL Lite 1.2 by using kCBLDatabaseChangeNotification I have Scrolled the table to bottom to display latest data.But after updation to CBL Lite 1.3 whenever the change happened in database the table view by default scrolls to top once after that scrolls to bottom(I wrote the code for table scroll to bottom).


There’s no code in CBLUITableSource to explicitly scroll the view. So the scrolling must be a side effect of something else that’s happening, like inserting/deleting/moving rows. You’ll need to investigate and find a workaround.

CBLUITableSource isn’t magic, it’s just a useful utility class that saves you from re-implementing the wheel. Feel free to go into its source code and inspect or modify it.

As an alternative, you could always download CBL 1.2 and use the copy of CBLUITableSource.m from there, if you want the old behavior back.


Thank you @jens, I have drag and drop the CouchbaseLite framework into my IOS project, I couldn’t find the CBLUITableSource.m but I am able to access only CBLUITableSource.h. Please help me how to access CBLUITableSource.m file.


Finally, I resolved the issue by reloading the table in updateFrom delegate method.


You can clone the couchbase/couchbase-lite-ios repo from Github, or view the source code online.

If you copy the source into your project, you’ll need to rename the class so it doesn’t conflict with the one in the framework. I suggest removing the “CBL” prefix and adding your own.