Preserve position when moving UIView in hierarchy (paste-in-place)

前端 未结 2 1643
长发绾君心
长发绾君心 2020-12-30 11:44

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

相关标签:
2条回答
  • 2020-12-30 12:31

    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.
    0 讨论(0)
  • 2020-12-30 12:44

    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.

    0 讨论(0)
提交回复
热议问题