Move all subviews to container view keeping positions and constraints Move all subviews to container view keeping positions and constraints xcode xcode

Move all subviews to container view keeping positions and constraints


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.


You can do this in Xcode 6 by using cut&paste to a separate view (which you can later drag around to wherever you actually need it).