Move or copy view controller from one storyboard to another

52,879

Solution 1

Yes, it is possible.

  1. Select controllers you want to copy
  2. Press Command + C
  3. Open your second storyboard file
  4. Press Command + V

Note: "IBOutlets remains as is after copying(Verified on Xcode 6.3.2)."

Solution 2

It is possible to copy, but you have to open both storyboards at once in one project, and then copy and paste.

Solution 3

In Xcode 8, if specifically you want to move view controllers to another storyboard, just select the view controller(s) which you want to move by Cmd + click the view controller. Keeping them selected, Go to the Editor tab and Choose Refactor to Storyboard. It will ask you the name of the new storyboard file and press Enter.

A new storyboard file will be created with your selected view controllers in it. In the Main.storyboard, you will see a Storyboard Reference object in place of that view controller, which is your reference to the new storyboard you just made.

Solution 4

Copy-paste (Command+C, Command+V) works fine but remember to resolve outlet connections because Xcode seems to keep the original connections: close/reopen project, delete what's wrong and reestablish missing connections.

Solution 5

It´s possible to copy/paste but it only works if you have both Storyboards open side by side using Xcode´s Assistant Editor.

Share:
52,879

Related videos on Youtube

Vladimir Berezkin
Author by

Vladimir Berezkin

Updated on April 27, 2021

Comments

  • Vladimir Berezkin
    Vladimir Berezkin about 3 years

    I have several UIViewControllers in one Storyboard. Now I want to move some UIViewControllers to another Storyboard. Is it possible?

  • Vladimir Berezkin
    Vladimir Berezkin over 11 years
    i mean to move viewcontroller scene between storyboards in xcode
  • Vern Jensen
    Vern Jensen over 10 years
    This is excellent. I had been having issues when I manually copied my Storyboard in the Finder, copying it from an Apple sample project to my own project. The issues disappeared when I created the storyboard in the target project, then copied and pasted the contents in. Strange.
  • new2ios
    new2ios about 9 years
    It is working solution @Fady Kamal. Sometimes it is not working from the first time - it depends where the focus is on X-Code.
  • new2ios
    new2ios about 9 years
    Ok, @Rahul, but what happens with outlets - are they properly set, or I have to relink them?
  • Alvin George
    Alvin George over 8 years
    You can try duplicate too. Command + D or Edit-Duplicate will do the magic !
  • Akhil Balakrishnan
    Akhil Balakrishnan over 8 years
    I have tried to copy view controllers between two projects like this in Xcode 6.4 and it worked perfectly.
  • Chen Li Yong
    Chen Li Yong over 8 years
    This is actually what resolves my problem. BOTH storyboards have to be open using assistant editor! Thank you!
  • Alix
    Alix about 8 years
    Question was to move/copying VC in Storyboard. I dont think so your answer anywhere solving this problem.
  • Chucky
    Chucky almost 8 years
    If you ask me, this doesn't work in Xamarin. My outlets now don't update automagically when trying to add event handlers to buttons, for example.
  • Nicolas Manzini
    Nicolas Manzini almost 8 years
    You must select the view controller, not the view controller scene. it work perfectly even from one project to another
  • nefarianblack
    nefarianblack over 7 years
    While pasting, you will have to select the view controller area where you usually drop UI elements.
  • Hobo Joe
    Hobo Joe over 7 years
    This is extremely helpful. It preserves all the existing relationships and segues, unlike other methods.
  • MikeG
    MikeG about 7 years
    Confirmed still working in Xcode 8.3.2 . IBOutlets, IBActions, storyboard ID's, segues all copied over perfectly. I didn't break any segues though, , meaning I didn't remove a view controller on the end of a segue and put it into another storyboard. I did copy segues, but only where I copied the origin view controller and the destination view controller and moved them to the new storyboard together
  • Tejas K
    Tejas K about 6 years
    The view controller gets copied exactly on top of the existing view controller. You need to drag it from on top of it.
  • Stamp
    Stamp over 4 years
    Didn't work for me at first. Lots of crashes (Xcode 11). Worked on the 4th or 5th attempt.
  • David
    David over 4 years
    But you can't refactor to an existing storyboard?
  • Gigi
    Gigi over 2 years
    In XCode 13 does not work.
  • Jordan
    Jordan over 2 years
    I just did this in Xcode 13.1 and it still works fine. Thanks!