Quantcast
Channel: Coding and Programing » iphone
Viewing all articles
Browse latest Browse all 10

detect end of loading of UITableView

$
0
0

Problem And Question

I want to change the offset of the table when the load is finished and that offset depends on the number of cells loaded on the table.

Is it any way on the SDK to know when a uitableview loading has finished? I don’t see nothing neither on delegate nor on data source protocols.

I can’t use the count of the data sources because the loading of the visible cells only.

Best Solution And Answer

Improve to @RichX answer:
lastRow can be both [tableView numberOfRowsInSection: 0] - 1 or ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row.
So the code will be:

-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
        //end of loading
        //for example [activityIndicator stopAnimating];
    }
}

UPDATE:
Well, @htafoya’s comment is right. If you want this code to detect end of loading all data from source, it wouldn’t, but that’s not the original question. This code is for detecting when all cells that are meant to be visible are displayed. willDisplayCell: used here for smoother UI (single cell usually displays fast after willDisplay: call). You could also try it with tableView:didEndDisplayingCell:.


Viewing all articles
Browse latest Browse all 10

Trending Articles