Scrolling when a UIScrollView inside a UIScrollView

I want to add a second UIScrollView inside the first page of another UIScrollView. To go to page 2 of the first UIScrollView, now I need to scroll right below the second under the UIScrollView. Is there a way to ignore the right miss while on page 3 of the second UIScrollView, so can I go to page 2 of the first UIScrollView? I hope you understand my problem: /

UIScrollView inside of UIScrollView

+4
source share
1 answer

There are different approaches. You could implement delegation methods for the scroll view (void)scrollViewDidScroll:(UIScrollView *)sender and (void)scrollViewDidEndDecelerating:(UIScrollView *)sender to observe when scrolling the view. Thanks to this, you can track the index of the current page of the second scrollview. I haven't tried it yet, but something like this should go in the right direction:

 - (void)scrollViewDidScroll:(UIScrollView *)sender { if (indexOfSecondScrollView == 3 && secondScrollView.contentOffSet.x >= 3*second_scroll_view_screen_width){ firstScrollView.scrollEnabled == YES; //move firstScrollView doing something like this: [self.scrollView scrollRectToVisible:CGRectMake(x,y,width,height) animated:YES]; } else{ firstScrollView.scrollEnabled = NO; } } 
+2
source

Source: https://habr.com/ru/post/1443941/


All Articles