ListView for Xamarin.iOS: Load-on-demand
There are certain scenarios typically with remote data over the wire where data needs to be loaded continuously on small portions. TKListView can load data on demand.
Enabling the load-on-demand
To enable the load on demand feature, you shoud set the LoadOnDemandMode
property to one of the two supported modes Auto
or Manual
.
When using the Auto
LoadOnDemand mode the LoadOnDemandBufferSize
of type int
property defines the number of cells from the bottom of the list view up at which to start requesting data.
After setting the desired LoadOnDemandMode
you should implement the TKListViewDelgate
method ShouldLoadMoreDataAtIndexPath:
to determine if more data should be loaded. After the data is loaded you should notify the ListView by calling its DidLoadDataOnDemand
method:
When using Manual
LoadOnDemand mode, TKListView appends a special cell at the end of the list. Touching this cell starts the process of loading more data. In this scenario you should process CellForItem
method of TKListViewDataSource and check whether this is a "load on demand cell":
ListView Load On Demand example can be found in our Native Xamarin.iOS examples.