[英]vertical UIScrollView inside horizontal UIPageViewController not scrolling
I've got a UIPageViewController that allows for standard horizontal swiping between a basic set of ViewControllers. 我有一个UIPageViewController,它允许在一组基本的ViewControllers之间进行标准的水平滑动。
Those views' vertical length is quite long, requiring a UIScrollView to allow for vertical scrolling only. 这些视图的垂直长度非常长,需要UIScrollView才允许垂直滚动。 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. 不幸的是,scrollview似乎没有在PageViewController内滚动。
I've set the scrollView contentSize which is a value larger than the container. 我已经设置了scrollView contentSize,它是一个大于容器的值。 I've enabled the delegate to be "self", and the scrollViewDidScroll method never gets called when swiping.
我已经将委托设置为“self”,并且在滑动时永远不会调用scrollViewDidScroll方法。
Is there something about the PageViewController and it's gesture recognizers that block the ScrollView's? 是否有关于PageViewController和它的手势识别器阻止ScrollView的东西?
I had the same issue. 我遇到过同样的问题。 Assume, that you are using Autolayout.
假设您正在使用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
: 这解决了你的问题
UIGestureRecognizerDelegate
:
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.