碰到了问题,搜了一下,搞定,方法不错,很巧
Finding the direction of scrolling in a UIScrollView?
当然,这么写也行
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//Selected index's color changed.
static float newx = 0;
static float oldIx = 0;
newx= scrollView.contentOffset.x ;
if (newx != oldx ) {
//Left-YES,Right-NO
if (newx > oldx) {
self.scrollLeftOrRight = NO;
}else if(newIndex < oldIndex){
self.scrollLeftOrRight = YES;
}
oldx = newx;
}
}
//Selected index's color changed.
static float newx = 0;
static float oldIx = 0;
newx= scrollView.contentOffset.x ;
if (newx != oldx ) {
//Left-YES,Right-NO
if (newx > oldx) {
self.scrollLeftOrRight = NO;
}else if(newIndex < oldIndex){
self.scrollLeftOrRight = YES;
}
oldx = newx;
}
}