iOS的嵌套UIScrollViews使用自动版式 [英] iOS Nested UIScrollViews using AutoLayout

查看:168
本文介绍了iOS的嵌套UIScrollViews使用自动版式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以上是我的程序应该是什么样子的布局的一个例子。
屏幕应该有一个简单的头部查看了顶部和下面的剩余空间用于显示其他内容。
这等内容基本上是3页的东西。
家长应滚动视图在一次显示一个页面,但可以使用分页去其他的人向左或向右滚动。
问题是,在这些页面中都将有不同的高度。此外,通过在父视图中使用分页,垂直滚动也将被分页,所以我想我必须分配一个滚动视图为每个单独的页面,每个分页禁用。
这个过程是自动布局相当烦人,因为我必须手动计算,并在此改变intrinsicContentSize为每一个视图,并在viewcontrollers一个自定义的方法返回基于他们利用其子女和约束的内在内容大小的高度。然后,我需要用这个高度来约束的观点的宽度和高度,使容器scrollviews能够使用自动布局的contentsizes来计算。
我能得到的东西展现出来使用容器uiviews和uiscrollviews但接收事件是父滚动视图的唯一滚动型一塌糊涂。为什么孩子滚动意见不响应?

Above is an example of the layout of how my program should look. The screen should have a simple header view up top and the remaining space below it is used to display other content. This other content is basically 3 pages of stuff. The parent scrollview should display one page at a time but can scroll left or right using paging to get to the other ones. The problem is that each of these pages is going to have different heights. Also, by using paging in the parent view, vertical scrolling also gets paged so I think I have to assign a scrollview for each individual page, each with paging disabled. This process is fairly annoying for autolayout because I have to manually calculate and overide intrinsicContentSize for every single view and make a custom method in viewcontrollers to return the height based on the intrinsic content sizes of its children and constraints used on them. I then need to use this height to constrain the widths and heights of the views so that the container scrollviews are able to calculate their contentsizes using autolayout. I can get stuff to show up using a mess of container uiviews and uiscrollviews but the only scrollview that receives events is the parent scroll view. Why are the child scroll views not responding?

推荐答案

我有嵌套UIScrollViews类似的问题。我发现这个视频从WWDC(以下链接)2010,真正帮助我了解如何使用分页的UIScrollView里面的孩子UIScrollViews工作,我设法修正错误我必须按照此视频的步骤,并在看样品$ C $角

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.

  • Designing Apps with Scroll Views (WWDC 2010)
  • PhotoScroller sample code

注意:的PhotoScroller code已被更新,因为视频录制,支持ARC,故事和UIPageViewController。我建议先考虑看看在样品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.

希望这有助于!

这篇关于iOS的嵌套UIScrollViews使用自动版式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆