“If this property is NO, scrolling is permitted in both horizontal and vertical directions. If this property is YES and the user begins dragging in one general direction (horizontally or vertically), the scroll view disables scrolling in the other direction. If the drag direction is diagonal, then scrolling will not be locked and the user can drag in any direction until the drag completes. The default value is NO”
- (id)initWithFrame:(CGRect)frame { _scrollDirection = 0; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (self.scrollDirection == 0){//we need to determine direction //use the difference between positions to determine the direction. if (abs(self.scrollViewStartPosPoint.x-scrollView.contentOffset.x)< abs(self.scrollViewStartPosPoint.y-scrollView.contentOffset.y)){ //Vertical Scrolling self.scrollDirection = 1; } else { //Horitonzal Scrolling self.scrollDirection = 2; } } //Update scroll position of the scrollview according to detected direction. if (self.scrollDirection == 1) { scrollView.contentOffset = CGPointMake(self.scrollViewStartPosPoint.x,scrollView.contentOffset.y); } elseif (self.scrollDirection == 2){ scrollView.contentOffset = CGPointMake(scrollView.contentOffset.x,self.scrollViewStartPosPoint.y); } }