Miro
Miro

Reputation: 5337

vertical UIScrollView inside horizontal UIPageViewController not scrolling

I've got a UIPageViewController that allows for standard horizontal swiping between a basic set of ViewControllers.

Those views' vertical length is quite long, requiring a UIScrollView to allow for vertical scrolling only. So, horizontal swipes to change the page, and vertical theoretically to scroll the page content.

Unfortunately the scrollview does not seem to scroll inside the PageViewController.

I've set the scrollView contentSize which is a value larger than the container. I've enabled the delegate to be "self", and the scrollViewDidScroll method never gets called when swiping.

Is there something about the PageViewController and it's gesture recognizers that block the ScrollView's?

Upvotes: 4

Views: 1850

Answers (2)

IgorNikolaev
IgorNikolaev

Reputation: 1063

I had the same issue. Assume, that you are using Autolayout. If so, explicitly set size like this:

CGRect screenRect = [[UIScreen mainScreen] bounds];
[self.mainScrollView setContentSize:CGSizeMake(screenRect.size.width, 568+300)];

Upvotes: 1

Esqarrouth
Esqarrouth

Reputation: 39201

This solves your problem UIGestureRecognizerDelegate:

func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return true
}

Upvotes: -1

Related Questions