Copy view controller from one project to another - ios

I am working on project X. I needed to add component Y to the project. So I go and create component Y as a separate project, say Project W. Now I need to copy Project W into Project X as component Y. How do I do that? I don't mind copying one piece at a time such as: copy ViewControllers in storyboard manually, and then copy the classes manually. Thanks for any help.

Go to the ViewController or storyboard object, select the top bar so you're selecting the whole thing, and then hit COMMAND + C to copy.
Then go to your other project, and open up Storyboard, and place your cursor down onto the open field, and hit COMMAND + V to paste it.
Typically you then have to zoom out on storyboard scene to see it, as for some reason it'll place it down all cattywampus. However, you'll see the files appear in your list of scenes (middle or left panel).

Related

Controls Inspector Below Identity Inspector Missing in Xcode 10

I recently updated my Xcode 9 to Xcode 10.1. At the right bottom of the inspector pane for storyboard, the searchbox that always used to be there for finding controls such as ViewController, UIImageView, UITextfield etc. and dragging them to the storyboard is missing. I can't find it anywhere in the menu structure.
Does anyone know how to get it to display?
It goes top right, left to the Show Standard Editor button.
you can access it with shift + cmd + L too.
Don't forget to select a xib or storyboard file first.
And it name is Library by the way.

How to select multi controllers in storyboard?

Here is my storyboard:
and I know it looks crazy , so I plan to use storyboard reference to move the right part of the storyboard in to a new storyboard. and I googled ,it says press the shift can multi selected controllers ,but it dose not work.
so how can I move multi controllers at same time?
I have tried to use mouse ,but it only selected 5 controllers in the upper part 。
But I want to select all of them.
Just select them by dragging mouse:
And then press key Command + C to copy them,
then open the second Storyboard, press key Command + V to paste them.
Yes, it is possible.
Select controllers you want to copy
Press Command + C
Open your second storyboard file
Press Command + V
It is very easy no any key is required just select using mouse
i post the gif..
Hold down Option and scroll mouse wheel until minimum resolution, 6.25%
Click and Drag to select all view controllers - or ones you want to copy.
Click Edit->Copy or Use Ctrl+C
Go to Target Storyboard. Click Edit->Paste or Ctrl+V.
I tested this with about 40 controllers,looks like you have around that much. Old question, but new answer! :). In case anyone still looking.
Also I key-bind Option+Z to "Zoom to Fit" and this centers and displays all controllers with the Interface Builder canvas.

How do I change the stacking order of objects in Xcode 6?

In my projects when I forget to add something in the Main Storyboard, I always have to redo the entire thing if I want to change the "layer order." For example, if I want to add an Image View (with full screen constraints) as the background after I've already some other elements, it will cover them. How do I change the "layer" that each element is on without deleting and remaking them? Thanks.
Click on the element you want to arrange, hit Editor > Arrange > Send to Back (or send backward depending on how you want to arrange it)

Xcode 5 - Paste in place/master page/header?

Is there anyway to "paste in place" in Xcode 5? I've been trying to copy a label and paste it in place as a header on all my pages. Sounds simple but I can't find a simple solution. The "paste & preserve formatting" is greyed out every time I try to use it. Is there something like a master page in Xcode where I can just setup a header?
Select the subviews you would copy.
Menu/Editor/Embed In > View
Cut/Copy/Past the view in another view or another Xib
Select the view
Menu/Editor/UnEmbed
Done :)

Can I copy a storyboard from one project to another project?

To reuse a storyboard, could I simply copy it from one project to another project (then make modification to the storyboard as required)?
Yes you can, just make sure they are selected as your main storyboards as per image below.
As #Muhammad said you can and it is very simple!
You just have to drag the Storyboard file from one project to another and select all options (The same procedure as importing anything else!).
Next, you just need to go to your project options by clicking on the project icon in the left upper side of project navigator.
Then you just need to select this storyboard to be your storyboard and that's it.
Method 1
Select the View Controller in the storyboard and press Command + C to copy. Then press Command + V to paste in the second storyboard. Check the document outline to see where it was pasted to.
Method 2
Right click the storyboard file in the Project Navigator and select Open As > Source Code. Scroll down the XML code until you find your View Controller. It will look something like this:
<!--My View Controller-->
<scene sceneID="tne-QT-ifu">
...
</scene>
Copy this and paste it in the second project's storyboard file.
Notes
You must also copy over the view controller swift file, of course, but the outlets shouldn't need to be reconnected.
It's simple. Just follow these steps:
Press cmd + D while selecting your desired storyboard scene. It will create a duplicate copy of your selected scene.
Press cmd + x to cut the scene from the existing project.
Press cmd + v into the storyboard section of the second project.
Cheers.

Resources