简体   繁体   中英

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?

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)];

This solves your problem UIGestureRecognizerDelegate :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM