2

im atempting to do a facebook type load more data and right now it works, but very laggy on the device because its asking the server to get anything that isnt there already, then calling a scroll all the way down function (because somehow when i reload the data it scrolls to the top). If there would be a way to prevent scrolling to the top that would be great. But my main thing is, is there a way to detect when i scrolled down, and LET GO (stopped scrolling) as in i scrolled past what i have, then it went back to its possition and then calls my methods... Currently it keeps getting called when the scroll is greater then the height of the UITableView heres the code

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat height = scrollView.frame.size.height;

    CGFloat contentYoffset = scrollView.contentOffset.y;

    CGFloat distanceFromBottom = scrollView.contentSize.height - contentYoffset;

    if(distanceFromBottom < height)
    {
        [getMessage removeAllObjects];
        [self loadMessages];
        [self.tableView reloadData];
        [self scrollAllTheWayDown];
    }
}
4

1 回答 1

4

UIScrollViewDelegate 方法

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;

做你想做的事。它在用户停止滚动后被调用,您可以在此时检查 scrollOffset 以查看是否应该触发刷新代码。(您将使用 scrollViewDidScroll 更新视图以显示如果他放手将发生用户更新)

于 2013-05-09T19:58:07.100 回答