views:

112

answers:

2

Hi is there a method / possibility to run a function when the scrollview is scrolling?

i found scroll start and scroll end solutions but nothing like a onIsScrolling ...

is there a built in solution? or whats the best workaround (nstimer)?

thanks Alex

+1  A: 

UIScrollViewDelegate provides the following:

– scrollViewDidScroll:
– scrollViewWillBeginDragging:
– scrollViewDidEndDragging:willDecelerate:
– scrollViewShouldScrollToTop:
– scrollViewDidScrollToTop:
– scrollViewWillBeginDecelerating:
– scrollViewDidEndDecelerating:

in particular:

– scrollViewDidScroll:
wkw
thanks. i will try to implemnt it. after that i will post it here.
Alex Milde
A: 

Thanks a lot for the scrollViewDidScroll tip. heres the implemtation sample:

@interface YourClass : UIViewController  <UIScrollViewDelegate>
{
    UIScrollView    *theView;
}

@end

in .m file:

- (void)loadView 
{
    theView = [[UIScrollView alloc] initWithFrame:
CGRectMake(0, 10, 300, 300)];
    theView.delegate = self;

    [self.view addSubview:theView];

    theView.contentSize = CGSizeMake(500, 500); 
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"SCROLL SCROLL SCROLL YOUR BOAT");
}
Alex Milde