如何配置uiscrollview加载数据,当它到达底点

我正在制作一个应用程序,就像Instagram , Path等。我需要知道,触发点,如果用户滚动到底部点并且当它反弹时,我需要进行一些调用。 我如何获得该触发点?

查看UIScrollviewDelegate方法: http : //developer.apple.com/library/ios/#documentation/uikit/reference/uiscrollviewdelegate_protocol/Reference/UIScrollViewDelegate.html

您可能希望查看– scrollViewDidEndDragging:willDecelerate:– scrollViewDidEndDecelerating:然后在这些方法中使用scrollView.bounds检查scrollview的当前可见rect,以查明用户是否已滚动到底部。

您可以查看以下代码。 它可能会帮助你。

 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 60.0, 0.0); [scrollView scrollRectToVisible:CGRectMake(0, scrollView.contentSize.height, scrollView.frame.size.width, 160.0) animated:YES]; if ([scrollView viewWithTag:5000]) { UIView *view = (UIView*)[scrollView viewWithTag:5000]; [view removeFromSuperview], view = nil; } UIView *viewloader = [[[UIView alloc] initWithFrame:CGRectMake(0.0, scrollView.contentSize.height, scrollView.contentSize.width, 160.0)] autorelease]; viewloader.tag = 5000; UILabel *lblloader = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, scrollView.frame.size.width-0.0, 60.0)] autorelease]; lblloader.backgroundColor = [UIColor clearColor]; lblloader.tag = 550; lblloader.textColor = [UIColor whiteColor]; lblloader.textAlignment = NSTextAlignmentCenter; lblloader.text = @"Click to load more data."; [viewloader addSubview:lblloader]; viewloader.backgroundColor = [UIColor darkGrayColor]; UIButton *btnLoad = [UIButton buttonWithType:UIButtonTypeCustom]; btnLoad.frame = lblloader.frame; btnLoad.backgroundColor = [UIColor clearColor]; [btnLoad addTarget:self action:@selector(callForMoreData:) forControlEvents:UIControlEventTouchUpInside]; [viewloader addSubview:btnLoad]; [scrollView addSubview:viewloader]; }