将所有子视图容器视图保存位置和约束 [英] Move all subviews to container view keeping positions and constraints

查看:100
本文介绍了将所有子视图容器视图保存位置和约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是X code 5和自动布局在我的项目。我有一个的.xib 有很多他们之间的子视图和约束的文件。现在我需要建立一个中间全屏容器视图,并把所有子视图那里。所以现在我有查看 - >子视图,我想查看 - >集装箱取景>子视图。当我做这在IB通过拖动子视图倒入容器中来看,他们都得到中心,所有的约束迷路。这将是一个有点难以手动恢复所有约束。有一个聪明的办法做到这一点保持所有子视图的立场和约束?

I'm using Xcode 5 and autolayout in my project. I have a .xib file with a lot of subviews and constraints between them. Now I need to create an intermediate fullscreen container view and put all subviews there. So now I have view->subviews, and I want view->container view->subviews. When I do this in IB by dragging subviews into container view, they all get centred and all constraints get lost. It's going to be a little hard to restore all constraints manually. Is there a smart way to do this keeping all subviews' positions and constraints?

推荐答案

添加您的容器欣赏到层次(以获得对象ID)在Interface Builder和关闭视图。编辑的.xib 手动档,在文本编辑器,并将所有子视图是容器视图下。约束在IB创建了以IB对象ID引用,所以你必须从引用与容器的上海华更换制约;快速更换运行就足够了。

Add your container view to the hierarchy (to get an object ID) in Interface Builder and close the view. Edit the .xib file manually, in a text editor, and move all subviews to be under the container view. Constraints are created in IB with references to IB object IDs, so you will have to replace the constraints from referencing the superview with the container; a quick replace run should be sufficient.

这篇关于将所有子视图容器视图保存位置和约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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