Move or copy a view controller from one storyboard to another

I have several UIViewControllers in one storyboard. Now I want to move part of the UIViewControllers to another storyboard. Is it possible?

+51
ios xcode uiviewcontroller storyboard
Nov 16 '12 at 13:12
source share
8 answers

Yes it is possible.

  • Select the controllers you want to copy.
  • Press Command + C
  • Open the second storyboard file
  • Press Command + V

Note: IBOutlets remains the same as after copying (tested on Xcode 6.3.2).

+103
Nov 16 '12 at 13:21
source share

You can copy, but you need to simultaneously open both storyboards in the same project, and then copy and paste.

+16
Apr 08 '15 at 9:49
source share

In Xcode 8, if you specifically want to move the view controllers to another storyboard, simply select the view controller that you want to move using Cmd + click on the view controller. Save them, go to the "Editor" tab and select "Refactor to Storyboard". He will ask you the name of the new storyboard file and press "Enter".

A new storyboard file will be created with the view controllers of your choice. In Main.storyboard, you will see the Reference Storyboard object instead of this view controller, which is your link to the new storyboard that you just created.

+11
Jan 20 '17 at 6:09
source share

Copy-paste (Command + C, Command + V) works fine, but don't forget to allow output connections, because Xcode seems to support the original connections: close / reopen the project, delete something incorrectly and restore the missing connections.

+3
Oct 31 '15 at 19:01
source share

You can copy / paste, but it only works if you have two storyboards open side by side using the Xcode helper editor.

+1
Nov 09 '16 at 13:41
source share

Interface elements can be moved between Xib and Storyboard files using Copy / Paste .

This initially did not work for me. I tried to copy the UICollectionViewCell from the highlighted Xib to our main storyboard. The cell will not be copied to the Storyboard.

The solution was to select a specific parent in the storyboard. A UICollectionViewCell can be inserted as a child of a UICollectionView in a storyboard, but you cannot insert it otherwise.

If you are having trouble pasting a specific item, be sure to double-check that you have selected a valid parent before attempting to paste.

0
Jan 22 '16 at 21:01
source share

If you use Cut-n-Paste, you can workaround. The insert will not work if the ViewController is now in the file that is inserted. This makes it impossible to select a storyboard to insert. Xcode will refuse to paste. So you need to first drag the empty view controller into the storyboard from the library. Then select this viewController in the storyboard, and then the paste will work. After you finish the insert, you can remove the dummy viewController. You will no longer need.

0
Dec 26 '16 at 0:35
source share

I think it's possible....

 UIStoryboard *secondStoryBoard = [UIStoryboard storyboardWithName:@"secondStoryBoard" bundle:nil]; UIViewController *theTabBar = [secondStoryBoard instantiateViewControllerWithIdentifier:@"myTabBar"]; [self.navigationController pushViewController:theTabBar animated:YES]; 
-one
Nov 16 '12 at 13:20
source share



All Articles