How can I detect when my ShinobiGrid is scrolled?



What I would like to do is to load a certain amount of rows and when the user scrolls down, to load the next set of rows. Is there a way to do that?



Do you want to pre-load these rows for performance reasons?

Otherwise, ShinobiGrids works just like UITableView, it asks your data source for just the cells it needs to display everything that’s on screen. To help performance, it re-uses cells instead of allocating thousands of them. So all you need to do is answering the data source method calls, and if your data comes from some remote location and has latency, you could always return a skeleton grid cell with everything prepared as much as possible and load the remaining data in a background thread using GCD, which will then update the cell content asynchronically as soon as the data has arrived.

To answer the original question: No, there doesn’t seem to be a delegate method that lets you know, when the grid has been scrolled. At least there is nothing public in the headers. There are delegate methods of UIScrollView, of course, but if you try to register your object for those the grid view will not receive them anymore and things might go wrong.


Many thanks for the reply!


@pit_garbe - great explanation on cell reuse and the possible use of asynchronous loading! Just a quick note on your discussion of the UIScrollView delegate methods. The SGridDelegate inherits from the UIScrollViewDelegate and so you can actually have your grid delegate implement methods such as scrollViewDidScroll: and these will be called as the grid scrolls.  :sunglasses:


@rgrey  excellent hint, I missed that, in part since I haven’t yet made use of protocol inheritance.