3

图片

以上是我的程序外观布局的示例。屏幕顶部应该有一个简单的标题视图,下面的剩余空间用于显示其他内容。这其他内容基本上是3页的东西。父滚动视图应该一次显示一个页面,但可以使用分页向左或向右滚动以到达其他页面。问题是这些页面中的每一个都将具有不同的高度。此外,通过在父视图中使用分页,垂直滚动也会被分页,所以我认为我必须为每个单独的页面分配一个滚动视图,每个页面都禁用分页。这个过程对于自动布局来说相当烦人,因为我必须为每个视图手动计算和覆盖intrinsicContentSize,并在视图控制器中创建一个自定义方法,以根据其子项的内在内容大小和对它们使用的约束返回高度。然后我需要使用这个高度来约束视图的宽度和高度,以便容器滚动视图能够使用自动布局计算它们的内容大小。我可以使用一堆容器 uiview 和 uiscrollviews 来显示内容,但唯一接收事件的滚动视图是父滚动视图。为什么子滚动视图没有响应?然后我需要使用这个高度来约束视图的宽度和高度,以便容器滚动视图能够使用自动布局计算它们的内容大小。我可以使用一堆容器 uiview 和 uiscrollviews 来显示内容,但唯一接收事件的滚动视图是父滚动视图。为什么子滚动视图没有响应?然后我需要使用这个高度来约束视图的宽度和高度,以便容器滚动视图能够使用自动布局计算它们的内容大小。我可以使用一堆容器 uiview 和 uiscrollviews 来显示内容,但唯一接收事件的滚动视图是父滚动视图。为什么子滚动视图没有响应?

4

1 回答 1

2

I had similar issues with nesting UIScrollViews. I found this video from WWDC 2010 (link below) that really helped me to understand how to work with child UIScrollViews inside a paging UIScrollView, and I managed to fix the bugs I had by following the steps in this video and looking at the sample code.

Note: The PhotoScroller code has been updated since the video was recorded to support ARC, storyboards and UIPageViewController. I would suggest taking a look at the sample code first, and if you're not sure how it all works then watch the video.

Hope this helps!

于 2013-07-23T05:32:39.200 回答