I'm using the following code to detect if I've reached the bottom of a UITableView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if(self.tableView.contentOffset.y >= (self.tableView.contentSize.height - self.tableView.bounds.size.height)) {
NSLog(@"bottom!");
NSLog(@"%@", [self getLastMessageID]);
[self getMoreStuff:[self getLastMessageID]];
}
}
This works fine, but the only problem is when the user is pulling the tableview down (like pull to refresh) the code fires. How can I handle this?
try this way
if(self.tableview.contentOffset.y<0){
//it means table view is pulled down like refresh
return;
}
else if(self.tableView.contentOffset.y >= (self.tableView.contentSize.height - self.tableView.bounds.size.height)) {
NSLog(@"bottom!");
NSLog(@"%@", [self getLastMessageID]);
[self getMoreStuff:[self getLastMessageID]];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With