I have a 800 pixel high view that contains two primary views. I’d like the user to be able to swipe upwards / downwards between the sections. So I do this in my viewDidLoad:
_scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 400);
[_scrollView setContentOffset:CGPointMake(0, _containerView.frame.origin.y - 5) animated:NO];
_scrollView.pagingEnabled = YES;
_scrollView.alwaysBounceHorizontal = NO;
_scrollView.directionalLockEnabled = YES;
_scrollView.delegate = self;
I’m trying to initialize the view showing my bottom section — that’s where containerView is located. However, something odd happens in that whenever I just do a single tap upon the view, it shoots up to the view above it. After this happens, I can’t scroll down or anything.
I’ve only been able to scroll when I set the height to a large number like 1200px. Even then however, just one single tap on the bottom view will send it flying up to the top view. When I disable paging, the scrolling doesn’t go flying upwards on a single tap, but it means I have to manually manage the paging which is certainly less than ideal.
Any help?
The frame needs to be only the size that the user can see. 800px is bigger than the size of the iPhone screen. Content size needs to be double the frame that the user sees so paging will result in you moving between the two halves.