I load a portion of data from server and show it in UITableView. When the user scrolls tableView to the bottom of tableView (last cell), I load next portion of data and show it in new cells in tableView (add new cells).
My goal is to show in the bottom cell activity indicator while the data is loading from the server. Is there any standard beautiful and elegant way of implementation? I searched a lot, but found no answer.
Thanks a lot for the answer!
I keep a BOOL
isLoadingDatain my data model that tracks when data is loading. MytableViewControllerobserves this property via KVO and updates thetableView. I’ve used the following methods to show the activity indicator.in
tableView:viewForFooterInSection:, ifisLoadingData = YESreturn a view that contains aUIActivityIndicatorViewand aUILabelindicating that data is loading. Otherwise returnnil.if
isLoadingData = YES, innumberOfSectionsInTableView:add additional section to the count and return1for this section intableView:numberOfRowsInSection:. IntableView:cellForRowAtIndexPathreturn a “loading” cell that contains aUIActivityIndicatorViewand aUILabel.