X code 5自动布局 - 嵌入式表 [英] Xcode 5 Auto Layout - Embedded Tables

查看:89
本文介绍了X code 5自动布局 - 嵌入式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的UIScrollView 与几个的UITableView 的嵌入式它。我想允许每个表之多需要显示所有其细胞的扩大其高度。滚动视图的框架占据了整个屏幕,所以其 contentSize.height 需要扩大,以适应最大的表(我认为这是默认的行为,但我提到它只是万一我是不正确的)。可这都可以在我的故事板做了什么?或者,如果我将需要添加code做到这一点,我发现本教程,但它是iOS 6的? - 已改变任何code这个约束的东西适用于iOS 7

I have a UIScrollView with several UITableViews embedded in it. I want to allow each table to expand its height as much as is needed to display all of its cells. The scroll view's frame takes up the whole screen, so its contentSize.height need to expand to fit the biggest table (which I think is the default behavior, but I mention it just in case I'm incorrect). Can this all be done on my storyboard? Or if I will need to add code to do it, I found this tutorial, but it's for iOS 6 - has any of the code for this constraint stuff changed for iOS 7?

推荐答案

如果你事先知道每个表的多少空间占用你能做到纯粹的故事板,但因为每个UITableView的也是一个滚动视图的默认行为一个UITableView是填补与内容分配的大小和滚动如果有溢出。

If you know in advance how much room each table takes up you can do it purely in your storyboard, but because each UITableView is also a scrollview the default behavior of a UITableView is to fill the assigned size with content and scroll if there is overflow.

如果你不知道在设计时表的高度,则需要在运行时进行设置。见<一href=\"http://stackoverflow.com/questions/16096021/autolayout-a-uiscrollview-to-fit-content-including-subviews-and-grouped-tables/16127931#16127931\">Autolayout一个UIScrollView适合的内容,包括子视图和分组表一个例子,简单的答案是一个高度约束添加到您的表格,将其拖动到你的控制器的电源插座,然后设置的高度,当你知道它。

If you do not know the height of the tables at design time, you will need to set them at run time. See Autolayout a UIScrollView to fit content including subviews and grouped tables for an example, the short answer is to add a height constraint to your table, drag it into your controller as an outlet, and then set the height when you know it.

这篇关于X code 5自动布局 - 嵌入式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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