user4806509
user4806509

Reputation: 3011

Adding new top level UIView to Storyboard and preserving other UIView constraints

I have several UIViews on a storyboard with autolayout constraints attached to them, in the below example hierarchy:

View A

View B

— View B1

— View B2

View C

I am wanting to insert another UIView at the top level and drag into that all the other UIViews on the Storyboard but without messing up the constraints, for example:

View NEW

— View A

— View B

— — View B1

— — View B2

— View C

So far when dragging all UIViews into the new top level UIView, the constraints are broken and messed up.

Question:

1 - What are the techniques for preserving all constraints on the Storyboard when in the process of moving UIViews into another UIView?

Upvotes: 1

Views: 257

Answers (1)

hasan
hasan

Reputation: 24195

There is no techniques. no other way than to reset those.

Good news is that the sub-views will not get messy. e.g. B1 and B2 will preserving there constraints.

A workaround:

Create a temporery ViewController copy your root view to it. Then, delete all your subviews from the original ViewController (A,B,C). re-paste the root view, you copied to your original controller. Now you have an extra view that contains all view. use it as your new view.

Note: A copy and paste for the root view to the same viewcontrller may prevent losing outlets.

I just try it. and it worked :)

Upvotes: 0

Related Questions