Move or copy view controller from one storyboard to another
Solution 1
Yes, it is possible.
- Select controllers you want to copy
- Press Command + C
- Open your second storyboard file
- 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.
Related videos on Youtube
Vladimir Berezkin
Updated on April 27, 2021Comments
-
Vladimir Berezkin about 3 years
I have several
UIViewControllers
in one Storyboard. Now I want to move someUIViewControllers
to another Storyboard. Is it possible?-
Suragch almost 8 years
-
-
Vladimir Berezkin over 11 yearsi mean to move viewcontroller scene between storyboards in xcode
-
Vern Jensen over 10 yearsThis 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 about 9 yearsIt is working solution @Fady Kamal. Sometimes it is not working from the first time - it depends where the focus is on X-Code.
-
new2ios about 9 yearsOk, @Rahul, but what happens with outlets - are they properly set, or I have to relink them?
-
Alvin George over 8 yearsYou can try duplicate too. Command + D or Edit-Duplicate will do the magic !
-
Akhil Balakrishnan over 8 yearsI have tried to copy view controllers between two projects like this in Xcode 6.4 and it worked perfectly.
-
Chen Li Yong over 8 yearsThis is actually what resolves my problem. BOTH storyboards have to be open using assistant editor! Thank you!
-
Alix about 8 yearsQuestion was to move/copying VC in Storyboard. I dont think so your answer anywhere solving this problem.
-
Chucky almost 8 yearsIf 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 almost 8 yearsYou must select the view controller, not the view controller scene. it work perfectly even from one project to another
-
nefarianblack over 7 yearsWhile pasting, you will have to select the view controller area where you usually drop UI elements.
-
Hobo Joe over 7 yearsThis is extremely helpful. It preserves all the existing relationships and segues, unlike other methods.
-
MikeG about 7 yearsConfirmed 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 about 6 yearsThe view controller gets copied exactly on top of the existing view controller. You need to drag it from on top of it.
-
Stamp over 4 yearsDidn't work for me at first. Lots of crashes (Xcode 11). Worked on the 4th or 5th attempt.
-
David over 4 yearsBut you can't refactor to an existing storyboard?
-
Gigi over 2 yearsIn XCode 13 does not work.
-
Jordan over 2 yearsI just did this in Xcode 13.1 and it still works fine. Thanks!