8

in Xcode 4 IB is there a way to move a bunch of subviews from one superview to another without destroying their current layout?

This should be super easy, but when I try to copy/paste or move them in the view tree they all move to one position. I'd prefer not to reposition each of them manually after adding one extra view to hold part of a form for example.

In Flash there is Cmd-Shift-C for 'paste in place'. I'm looking for something similar in IB.

Esoteric Screen Name
  • 6,082
  • 4
  • 29
  • 38
konrad
  • 1,664
  • 2
  • 17
  • 36

2 Answers2

21

I had the same problem as OP, but I found a great solution on another thread. Answer by Jay: https://stackoverflow.com/a/16952902/2070758

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

  1. Select all views, labels etc, you want to move to the new super view
  2. Editor -> embed in view
  3. Move the newly created "container" view to the view you wanted to paste to originally
  4. Select the "container" view. Editor -> unembed. All the elements will be dumped into the super view, maintaining the layout.
Community
  • 1
  • 1
arinmorf
  • 1,374
  • 16
  • 27
4

Was looking for the solution to the same annoying limitation in xCode... found a trick:

  • Create a new UIViewController in IB
  • Paste all your stuff in its root view, the positions should be preserved
  • Copy and paste this root view where ever you need it,

worked for me but geeesh what a pain.

zukanta
  • 2,691
  • 2
  • 19
  • 25
  • I also found that that in some circumstances pasting preserves the original positions but as I try to avoid using IB altogether I never managed to pinpoint when exactly it happens. Thanks for the trick, it's better than nothing. – konrad Sep 02 '12 at 10:53