Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIScrollView direction from scrollViewWillBeginDecelerating

Is it possible to retrieve the direction that a UIScrollView is scrolling to, in the method;

-(void) scrollViewWillBeginDecelerating:(UIScrollView *)scrollView

If so, how can this be achieved?

like image 234
Thizzer Avatar asked Mar 11 '26 12:03

Thizzer


1 Answers

you could try something like this:

- (void)scrollViewDidScroll:(UIScrollView *)sender 
{
  xCoord = scrollview.contentOffset.x;
}

-(void) scrollViewWillBeginDecelerating:(UIScrollView *)sender 
{

   if (xCoord > scrollView.contentOffset.x) {
     //RIGHT
   } else if (xCoord < scrollView.contentOffset.x) {
     //LEFT
   }

}

store the x coord of the scrollViews contentOffset when it begins scrolling, then compare it in scrollViewWillBeginDecelerating

like image 67
Jamie Avatar answered Mar 13 '26 03:03

Jamie