Keep position when moving UIView in hierarchy (insert)

Is there a way in Xcode 4 IB to move a bunch of subviews from one supervisor to another without ruining their current layout?

It should be very simple, but when I try to copy / paste or move them to the view tree, they all move to the same position. I would prefer not to rearrange each of them manually after adding one additional view to store part of the form, for example.

Flash has Cmd-Shift-C for "paste in place." I am looking for something like this in IB.

+8
xcode4 interface-builder
Aug 20 '12 at 8:17
source share
2 answers

Looking for a solution with the same annoying limitation in xCode ... found a trick:

  • Create a new UIViewController in IB
  • Paste all your things in the root view, the positions should be saved.
  • Copy and paste this root view where you need it,

worked for me, but geeesh what a pain.

+4
Aug 30 '12 at 23:59
source share

I had the same problem as the OP, but I found a great solution in a different thread. The answer to this question is Jay: https://stackoverflow.com/a/166778/

Basically, you cannot copy / paste directly, but you can follow a few additional steps:

  • Select all views, labels, etc., you want to go to the new super view
  • Editor β†’ built-in view
  • Move the newly created β€œcontainer” view to the view you want to paste into the original
  • Select the container view. Editor β†’ unembed. All elements will be reset to the super-view, keeping the layout.
+20
Feb 19 '14 at 5:10
source share



All Articles