Is it possible to pass the scroll event to the desired nested UIScrollview?

I have two horizontal UIScrollViews with PagingEnabled. enter image description here

In portrait mode, everything works fine, but in the landscape I get a conflict between scroll views. For example, if the current view is ScrollView2.View2, and I scroll through ScrollView1.View3, ScrollView2, and also ScrollView1. It somehow gets the scroll event ScrollView1. As a result, I get ScrollView2.contentOffset equal to 0.0 (but it should be equal to X from View2, for example 384.0).

Is it possible to determine which scroll scrolls? I tried to fix it using the UIScrollViewDelegate methods, but it didn’t help me, and everything got worse if I put WebView instead of views.

EDIT: github.

, scrollview "didScroll" , . hitTest, .

+4
2

scrollview. , :

, UIScrollViews ( UIScrollView UIScrollView).

ScrollViews:

/*
 * User stopped dragging the innerScroll, the view is not decelerating 
 * and it is still not at its place. Lets help the view to get into right place.
 */
-(void) scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    if ([scrollView isEqual:innerScroll] && !decelerate) {
        if(scrollView.contentOffset.x <= view1.frame.size.width/2){
            [innerScroll scrollRectToVisible:view1.frame animated:YES];
        } else {
            [innerScroll scrollRectToVisible:view2.frame animated:YES];
        }
    }
}

/*
 * User stopped dragging the innerScroll and the View is decelerating. 
 * Lets skip an efforts of the View to get into right place and put it ourselves.
 */
- (void) scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
    if ([scrollView isEqual:innerScroll]) {
        if(scrollView.contentOffset.x <= view1.frame.size.width/2){
            [innerScroll scrollRectToVisible:view1.frame animated:YES];
        } else {
            [innerScroll scrollRectToVisible:view2.frame animated:YES];
        }
    }
}

UIScrollViews, UIScrollView .

-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if([scrollView isEqual:innerScroll]){
        if(CGRectIntersectsRect(scrollView.bounds, view1.frame)){
            if(CGRectIntersectsRect(filterScroll.bounds, view11.frame)){

            } else if(CGRectIntersectsRect(filterScroll.bounds, view22.frame)){

            }
            mainScroll.scrollEnabled = NO;
        } else if (CGRectIntersectsRect(scrollView.bounds, view2.frame)){
            mainScroll.scrollEnabled = YES;
        }
    }
}
0

scrollViewDidScroll:

, .

  • (void) scrollViewDidScroll: (UIScrollView *) scrollView

?

-(void)scrollViewDidScroll:(UIScrollView*)scrollView
{
    if(scrollView == ScrollView2)
    {
        // do stuff
    }
}
0

All Articles