How to have multiple scrollViews in one scrollView

I would like to have one large scrollview with horizontal scroll enabled. Inside this scrollView, I would like to (say) 5 other scrollviews that can be scrolled vertically.

Can someone point me in the right direction how to handle touches?

I am thinking of making two gesturerecognizer (1 for the crane and 1 for panning) and use the delta of the X and Y values ​​to calculate the horizontal or vertical scroll. After I checked the direction, I installed a large scroller or one of the scrollers to turn it on or off. Is it correct?


EDIT: Instead of using my method above, I was just able to add my 5 scrollviews (vertical scroll) to one large scrollview (horizontal), adding 5 scrollviews as a large spy. Perhaps this code can help someone, as well as provide sample code.

for (int i = 0; i < NumberOfVerticalScrollers; i++) {
        CGRect frame;
        frame.origin.x = self.scrollView.frame.size.width * i;
        frame.origin.y = 0;
        frame.size = self.scrollView.frame.size;

        UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:frame];
        scroller.directionalLockEnabled = YES;
        scroller.contentSize = CGSizeMake(320, 960);
        [self.scrollView addSubview:scroller];
}
self.scrollView.delegate = self;
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * NumberOfVerticalScrollers, self.scrollView.frame.size.height);
+3
source share
4 answers

You only need to create the main scroll, which can scroll horizontally, and just need to add other types of scroll in the main scroll using the method addSubView. iOS handles all the necessary events to properly handle scrolling. You only need to assign the right content size, and frameeach scroll.

+1
source

1 , . - , .

:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

,

:

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
+1

, - .

.

, , , , .

0

There is an application called "Pulse" that uses a vertical table where each table view cell can be scrolled horizontally and includes another table. This applies to caching and user interface events. You need to find an example of this and evaluate it for your purposes (perhaps turn the default implementation 90 degrees)

How to recreate a Pulse-like interface?

0
source

All Articles