Copy objects with sub items including 'constraints' using interface builder - iOS

interface-builder, ios, xcode

Solution

I had this same problem a while ago, let me know if it helps: Preserve position when moving UIView in hierarchy (paste-in-place)

(copied here for reference):

Original answer by Jay: https://stackoverflow.com/a/16952902/2070758

Basically, you can't copy/paste directly, but you can with some extra steps:

- Select all views, labels etc, you want to move to the new super view

- Editor -> embed in view

- Move the newly created "container" view to the view you wanted to paste to originally

- Select the "container" view. Editor -> unembed. All the elements will be dumped into the super view, maintaining the layout.

Problem

How do you copy a view or an object with sub objects with constraints to another view? Whenever I do this, the destination object is just a mish mash and fixing it is a pain.

Original source

Related problems