0

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

4

2 回答 2

2

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

您可能想查看– scrollViewDidEndDragging:willDecelerate:然后– scrollViewDidEndDecelerating:在这些方法中检查滚动视图的当前可见矩形,scrollView.bounds以了解用户是否已滚动到底部。

于 2013-04-09T09:32:46.683 回答
0

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

- (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];
}
于 2013-04-09T09:40:56.813 回答