UIScrollView的setContentSize休息查看与自动布局 [英] UIScrollView setContentSize breaks view with Auto Layout
问题描述
我在我的iPhone应用程序中使用自动布局,有一个的UIScrollView
。我需要的,而我的应用程序运行(这样设置内容大小 viewWillAppear中
在几个点来改变我的滚动视图的内容大小也没用,因为我看到这个建议在其他地方)。
I am using Auto Layout in my iPhone app and have a UIScrollView
. I need to change the content size of my scroll view at several points while my apps running (so setting the content size in viewWillAppear
is useless as I have seen this suggested in other places).
当我改变它,我的子视图跳一下,presumably,因为它打破了自动布局约束。
When I change it, my subviews jump about, presumably because it breaks the auto layout constraints.
那么,怎样才能进场我改变我的内容滚动视图大小启用自动布局?
So how can I approach changing my scrollview content size with auto layout enabled?
感谢。
推荐答案
我有同样的问题,我知道这不可能是最终的解决方案,但现在,而不是在调用此 viewWillLayoutSubviews
,通过将code里面的 viewDidLayoutSubviews
它让我设置contentSize后的的viewController做它的默认业务:)
I was having this same issue, and I know this can't be the final solution, but for now, rather than calling this in viewWillLayoutSubviews
, by putting the code inside viewDidLayoutSubviews
it allowed me to set the contentSize AFTER the viewController did it's default business :)
希望有所帮助。
这篇关于UIScrollView的setContentSize休息查看与自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!